{codes removed by moderator, posting grader cell codes is against community guidelines}
when train the model, i got error like this
how to fix this?
{codes removed by moderator, posting grader cell codes is against community guidelines}
when train the model, i got error like this
how to fix this?
can I know what is this reshaped_reconstructed?
You were suppose to add the code you wrote for the below code instruction
feed a batch to the VAE model
which would be vae of x_batch_train
Also heads, be careful about note sharing any of the grader cell codes, it is against community guidelines, in case the codes comes in error log that should be fine, but you do not post codes from any of the grade cell.
Regards
DP
I’m sorry about this, previously I had tried to find the cause of the error, it said reconstructed and x_batch_shape had different shapes. I tried reshaping reconstructed but the error still occurs.
So I’m still looking for a way to solve the error in the photo above, do you have any ideas?
Your issue lies here, can you share screenshot of that error??
Okay thank you for sharing the image,
your issue lies how you recalled the epsilon
Remember your inputs are basically mu and sigma
here you need to define the batch and dim using tf.shape for either mu or sigma (only either of the one)
Also batch would be mu or sigma of [0] and dim would mu or sigma of [1]
then epsilon calculate using tf.keras.backend.random_normal with a shape that includes(batch, dim)
then the z is calculated using mu + tf.exp(0.5 * sigma) * epsilon
Also make sure you go through my previous comment for the loss equation where reconstructed is basically vae of x_batch_train and no reshape.
Let me know if you still encountering any error.
Regards
DP
Thank you for your reply.
I have recalled epsilon according to your instructions, but I still get an Incompatible shapes error like this
Send me screenshot of the codes you corrected via personal DM. Don’t post codes here.
I’ve sent the codes via DM. Please check it
how about the step on the notebook:
“add the KLD regularization loss to the total loss (you can access the losses
property of the vae
model)”
Did you remove the code I mentioned and then run the cell?
That loss was suppose to be recall as just loss but you have recalled it has kl_loss
yes, I have removed the code you mentioned. but it still produces the same error, because the error occurred in the previous code which calculated the loss using mse_loss.
in the def decoder_model(latent_dim, convolutional_shape)
inputs = tf.keras.layers.Input(shape=(latent_dim,) WHYTHIS , WAS USED WITH LATENT_DIM?? REMOVE THAT COMMA
model = tf.keras.models.Model(inputs, outputs, name=“decoder”) (KINDLY REMOVE models from this code line
in the def vae model, place your loss(kl_loss) code after model recall for inputs and reconstructed, after which you add the loss to the model (also change the kl_loss to loss)
Also kindly run the cells from beginning one by one after you make the corrections.
let me know if the issue still persists.
Regards
DP
it’s solved, there is a lack of layers in my encoder model. Thank you Deepti for helping.