This is pure gold! I was working with the worldmodel and wanted to gain some knowledge of CNN-VAE, and I stumbled upon this video.......you have explained really, really well. Thanks a lot.
I am getting this error while executing vae.fit function TypeError: Tensors are unhashable. (KerasTensor(type_spec=TensorSpec(shape=(), dtype=tf.float32, name=None), name='tf.math.reduce_sum/Sum:0', description="created by layer 'tf.math.reduce_sum'"))Instead, use tensor.ref() as the key. I am using Tensorflow and Keras 2.4.0 can you please help me. I was trying to do this on CelbA dataset you mentioned at the end.
For anyone who is trying to do this and encounters an error saying "TypeError: Tensors are unhashable." during fitting, it is due to version incompatibility. Replacing "import keras" to "from tensorflow import keras" for TF >2.0 will solve the issue. As Keras is default API for TF > 2.0
thanks for this great video. I think y is actually the output loss of the model not reconstructed image. the final output of the model is the overall loss after the custom loss layer. and I think the reason in compiling the model we set ' loss = none ' is this.
It was a great explanation of VAE. Thanks for your sharing. I cannot understand that how can we calculate mean and standard deviation with a linear layer?
There's another error on the last double for loop, the solution is to change the dimensions of digits so that it doesn't use the last num_channels dimension: digit = x_decoded[0].reshape(img_width,img_height)
Thanks a lot for doing these videos ! Highly appreciated. I tried this program and got following error 'TypeError: You are passing KerasTensor(type_spec=TensorSpec(shape=(), dtype=tf.float32, name=None), name='tf.math.reduce_sum_5/Sum:0', description="created by layer 'tf.math.reduce_sum_5'"), an intermediate Keras symbolic input/output, to a TF API that does not allow registering custom dispatchers, such as `tf.cond`, `tf.function`, gradient tapes, or `tf.map_fn`. Keras Functional model construction only supports TF API calls that *do* support dispatching, such as `tf.math.add` or `tf.reshape`. Other APIs cannot be called directly on symbolic Kerasinputs/outputs. You can work around this limitation by putting the operation in a custom Keras layer `call` and calling that layer on this symbolic input/output...Can you please help?
Sir, I tried running the code in google colab but I am getting this error TypeError: You are passing KerasTensor(type_spec=TensorSpec(shape=(), dtype=tf.float32, name=None), name='tf.math.reduce_sum/Sum:0', description="created by layer 'tf.math.reduce_sum'"), an intermediate Keras symbolic input/output, to a TF API that does not allow registering custom dispatchers, such as `tf.cond`, `tf.function`, gradient tapes, or `tf.map_fn`. Keras Functional model construction only supports TF API calls that *do* support dispatching, such as `tf.math.add` or `tf.reshape`. Other APIs cannot be called directly on symbolic Kerasinputs/outputs. You can work around this limitation by putting the operation in a custom Keras layer `call` and calling that layer on this symbolic input/output.
Thanks for the most simplest and least intimidating video on the concepts and implementation ever. The concepts are crystal clear now. Please help in explaining how to save and then reload the same model again given that there is an Encoder/Decoder and Custom Layer as well. If I save the vae and load it back I face an error as - ValueError: Unknown layer: CustomLayer. Please help. Thanks
Thanks for this excellent tutorial. How do we write the samples of a certain distribution say (-3, 3) to a new folder rather than displaying on the figure? Pls include that code statement as well. Thanks in advance.
Thank you for the informative implementation. I am trying to use VAE for image-inpainting (starting point). I feed the network with incomplete images. I am not sure how to adapt this implementation such that loss is computed against the complete image, not the masked/incomplete ones. any leads?
First of all, thank you for your videos. I followed your model, and I am trying to tweak this VAE for anomaly detection. I trained using only 5s, and I want to see if it can detect 4s as an anomaly, for example. I tried prediction = vae.predict(sample), but the prediction and sample are identical every time! Something must be wrong because I expect that there should be a random sampling of the latent space for every prediction, thus shouldn't there at least be small variations? Could this be a biproduct of setting loss=None in the compiler and instead having the loss function defined in a custom layer?
when i run fit, i ran into an error of TypeError: You are passing KerasTensor(type_spec=TensorSpec(shape=(), dtype=tf.float32, name=None), name='tf.math.reduce_sum_3/Sum:0', description="created by layer 'tf.math.reduce_sum_3'"), an intermediate Keras symbolic input/output, to a TF API that does not allow registering custom dispatchers, such as `tf.cond`, `tf.function`, gradient tapes, or `tf.map_fn`. Keras Functional model construction only supports TF API calls that *do* support dispatching, such as `tf.math.add` or `tf.reshape`. Other APIs cannot be called directly on symbolic Kerasinputs/outputs. You can work around this limitation by putting the operation in a custom Keras layer `call` and calling that layer on this symbolic input/output.
is there a way to get rid of class CustomLayer(keras.layers.Layer) and write in simple python with a funtion that calculates the sum of the 2 loss terms ? The coode that follows does NOT work: def vae_loss(x, z_decoded): x = K.flatten(x) z_decoded = K.flatten(z_decoded) recon_loss = keras.metrics.binary_crossentropy(x, z_decoded) kl_loss = -5e-4 * K.mean(1 + z_sigma - K.square(z_mu) - K.exp(z_sigma), axis=-1) return K.mean(recon_loss + kl_loss) y = decoder(z) vae = Model(input_img, y, name='vae') vae.compile(optimizer='adam', loss=vae_loss) vae.fit(x_train, None, epochs = 10, batch_size = 32, validation_split = 0.2)
Hi Sir. Superb explanation from the start. I really appreciate it. By the way, have you try this VAE model with the movie star dataset that you mention in the last part of this video. Really looking forward for the explanation video on it
Sir i have a little concussion... Mean layer and variance layer are connected to the same layer then how mean layer computes mean and how variance layer computes variance?
Hi Sreeni, this video was really helpful. But, I am having tough time understanding, that why you used, mu + exp(sigma/2) * epsilon. The expression was mu + sigma * epsilon
Thanks for the video my data is a CSV file, and my vae is multi-input, what should I change in the customlayer() class or in this line "y = CustomLayer()([[x_in,y_in,z_in], z_decoded])" so it can work perfectly? thank you in advance sir
Hi, such a helpful video, thank you Sreeni! I was wondering, suppose i'm working on a different data and the latent vector dimension is say 128 instead of 2, how do we visualize and figure out each value of the sample_vector to generate data then?
thanks alot for this explanation. i am having a small error while trying to run the code. the fit step: vae.fit(x_train, None, epochs = 5, batch_size = 32, validation_split = 0.2) the error: TypeError: You are passing KerasTensor(type_spec=TensorSpec(shape=(), dtype=tf.float32, name=None), name='tf.math.reduce_sum_2/Sum:0', description="created by layer 'tf.math.reduce_sum_2'"), an intermediate Keras symbolic input/output, to a TF API that does not allow registering custom dispatchers, such as `tf.cond`, `tf.function`, gradient tapes, or `tf.map_fn`. Keras Functional model construction only supports TF API calls that *do* support dispatching, such as `tf.math.add` or `tf.reshape`. Other APIs cannot be called directly on symbolic Kerasinputs/outputs. You can work around this limitation by putting the operation in a custom Keras layer `call` and calling that layer on this symbolic input/output.
please help. I'm getting this error: TypeError: You are passing KerasTensor(type_spec=TensorSpec(shape=(), dtype=tf.float32, name=None), name='tf.math.reduce_sum_1/Sum:0', description="created by layer 'tf.math.reduce_sum_1'"), an intermediate Keras symbolic input/output, to a TF API that does not allow registering custom dispatchers, such as `tf.cond`, `tf.function`, gradient tapes, or `tf.map_fn`. Keras Functional model construction only supports TF API calls that *do* support dispatching, such as `tf.math.add` or `tf.reshape`. Other APIs cannot be called directly on symbolic Kerasinputs/outputs. You can work around this limitation by putting the operation in a custom Keras layer `call` and calling that layer on this symbolic input/output. what should I do?
Great explanation! How do we know which file from the github references this video? I can't find it by the Title of the files, and there are LOTs of files in the Github.
Yes, if you want the final VAE model to return the decoded image as output, then call(self,inputs) should return z_decoded instead of x. This took me awhile to realize, so I hope this helps! This video was tremendously helpful otherwise!
Thank you very much this was very useful and clear!!! Could you make a video on Beta VAE? It would be very interesting for anyone working with this models
Thanks that was a great expectation, but please help I can't train the model, as it's showing unhashable error when I applied custom layer for loss, and also when I created the loss function used by you and passed it in model.compile loss becomes null, please help in that I have wasted one whole day l, but couldn't detect the problem
If anyone is getting a type error when trying to run the code in google colab try this, Create a new code block and run these two lines !pip install tensorflow==1.13.2 !pip install q keras==2.0.8 then go to -> Runtime -> Restart Runtime and try to run the code again and it should work
I have been trying to implement VAE and this is the best video I have found. I followed each and every step but there is some weird error and many people are facing the same error who have watched your video. Can you help me with it?
Is it this error? TypeError: Cannot convert a symbolic Keras input/output to a numpy array. This error may indicate that you're trying to pass a symbolic value to a NumPy call, which is not supported. Or, you may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model.
my scatterplot of the latent space is never symmetrical, yaxis: (-4,0) and xaxis: (0,5), and i had (-4,0) and (-4,0) as well one time. does anybody know what my error could be?
I would like to thank you for your great work! You inspire many young programmers to learn more about machine learning! When I try to execute your code in my local GPU, I see the following error: Resource exhausted: OOM when allocating tensor with shape[32,32,29,29] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc. I tried to decrease batch size to 1 and still have an OOM error. Does anybody know what should I do next?
You are getting out of memory error. Try reducing batch size or resizing images to smaller size. OOM error is common with GPU with small memory, usually below 4GB.
I don't think there is anything like Conv[0] in the code. In case you are referring to conv_shape[0], it is explained in line 72 of the code. It is the shape of conv to be provided to decoder.
In a standard autoencoder, the input data is used both as the input and target for training. This means that the autoencoder tries to reconstruct the input data as closely as possible. The .fit method typically takes (X_train, X_train) format. VAE is a specific type of autoencoder that adds a constraint to the latent space by using probabilistic techniques. The objective of a VAE is not only to reconstruct the input data but also to learn a probabilistic representation of the data in the latent space. This latent space representation is then used to generate new data points by sampling from the learned distribution. So, in the context of Keras (or other deep learning frameworks), when fitting a VAE model, the .fit method often takes (X_train, None) instead of (X_train, X_train). The reason for this is that in a VAE, the model's output consists of both the reconstructed data and the parameters representing the latent space distribution. The None value is passed as the target because the target for the regularization loss is not the input data (X_train) but rather the desired shape of the latent space distribution (typically a standard normal distribution).
FYI, I was only able to get this example to work with keras 2.0.8 and. tensorflow 1.4 in python 3.5. I tried it in. python 3.8 with keras 2.4.3 and tensorflow would crash on the training part.
This is pure gold! I was working with the worldmodel and wanted to gain some knowledge of CNN-VAE, and I stumbled upon this video.......you have explained really, really well. Thanks a lot.
"Let me put it back to 42 or I cannot sleep". Best line ever haha
😄
I am getting this error while executing vae.fit function
TypeError: Tensors are unhashable. (KerasTensor(type_spec=TensorSpec(shape=(), dtype=tf.float32, name=None), name='tf.math.reduce_sum/Sum:0', description="created by layer 'tf.math.reduce_sum'"))Instead, use tensor.ref() as the key.
I am using Tensorflow and Keras 2.4.0 can you please help me. I was trying to do this on CelbA dataset you mentioned at the end.
Someone solved this problem? I'm in the same situation.
Stuck at the same error , please help
One of the best narrators I found for this kind of content. Thanks! Appreciate it and Hope to see more and more videos.
More to come!
This is the best tutorial on whole RUclips for VAE
Thank you :)
Thanks for the great explanation of VAE. Got more clarity on viewing your video after several attempts to understand VAE.
This explanation is like a Gem!!
Thanks
For anyone who is trying to do this and encounters an error saying "TypeError: Tensors are unhashable." during fitting, it is due to version incompatibility. Replacing "import keras" to "from tensorflow import keras" for TF >2.0 will solve the issue. As Keras is default API for TF > 2.0
I did change to "from tensorflow import keras" but the results of epoch is weird.
@@dwijokosuroso8970 Did you find any solution to this ? TIA
I cannot believe that RUclips algo took this long to recommend this channel.
Very informative content wrapped in a particularly personable style. A real stand-out among available videos on the subject matter. Thanks.
Glad it was helpful!
Pure Gold!
Please keep us updated about recent developments in AI.
Thanks!
Man i can't appreciate it enough, I was trying to learn VAE implementation this was the best tutorial I watched thanks sreeni keep it up!!
You're very welcome!
good video! Try not apologizing too much. You don't need to apologize for anything you do.
Hi @DigitalSreeni on line 152: If you want to return the output of the decoder, shouldn't you return z_decoded instead of x? Thanks for the video
One of the best tutorial on youtube to actually code VAE...👏👏
Glad you think so!
@@DigitalSreeni What are different performance metrics / benchmarks to know which method (error correction)
will be good for VAE?
This tutorial is a lifesaver!!!!
Awesome!
This is kinda magic! And what exactly my homework is, appreciated!
You are doing a great work !!!!! Thank you and keep teaching
Thank you for your time in explaining all the stuffs for newbies.
Thanks a lot for making series of videos related to auto encoders. I was looking for this content everywhere n found yours easy to digest 😊👌
Glad to hear that
thanks for this great video. I think y is actually the output loss of the model not reconstructed image. the final output of the model is the overall loss after the custom loss layer. and I think the reason in compiling the model we set ' loss = none ' is this.
It was a great explanation of VAE. Thanks for your sharing. I cannot understand that how can we calculate mean and standard deviation with a linear layer?
same question as mine docs.google.com/document/d/16D_vOcHAv4e7b430R5ojfLQObnjTCwt998rhzQ6sne4/edit
There's another error on the last double for loop, the solution is to change the dimensions of digits so that it doesn't use the last num_channels dimension:
digit = x_decoded[0].reshape(img_width,img_height)
Thanks a lot for doing these videos ! Highly appreciated. I tried this program and got following error 'TypeError: You are passing KerasTensor(type_spec=TensorSpec(shape=(), dtype=tf.float32, name=None), name='tf.math.reduce_sum_5/Sum:0', description="created by layer 'tf.math.reduce_sum_5'"), an intermediate Keras symbolic input/output, to a TF API that does not allow registering custom dispatchers, such as `tf.cond`, `tf.function`, gradient tapes, or `tf.map_fn`. Keras Functional model construction only supports TF API calls that *do* support dispatching, such as `tf.math.add` or `tf.reshape`. Other APIs cannot be called directly on symbolic Kerasinputs/outputs. You can work around this limitation by putting the operation in a custom Keras layer `call` and calling that layer on this symbolic input/output...Can you please help?
I am facing the same error. I think the tensorflow and/or keras version changed causing this error. Did you find any solution yet?
@@nirmalbaishnab4910 me too
Ηas anyone solved this????
@@dimitheodoro
Add this
import tensorflow._api.v2.compat.v1 as tf
tf.disable_v2_behavior()
@@sushilkhadka8069 thank you so much!
it works!!
I honestly don't know how to thank you so much !
Sir, I tried running the code in google colab but I am getting this error
TypeError: You are passing KerasTensor(type_spec=TensorSpec(shape=(), dtype=tf.float32, name=None), name='tf.math.reduce_sum/Sum:0', description="created by layer 'tf.math.reduce_sum'"), an intermediate Keras symbolic input/output, to a TF API that does not allow registering custom dispatchers, such as `tf.cond`, `tf.function`, gradient tapes, or `tf.map_fn`. Keras Functional model construction only supports TF API calls that *do* support dispatching, such as `tf.math.add` or `tf.reshape`. Other APIs cannot be called directly on symbolic Kerasinputs/outputs. You can work around this limitation by putting the operation in a custom Keras layer `call` and calling that layer on this symbolic input/output.
@@samedbey3548 Hello Sama, can you please clarify this a little more? What should I do to resolve the issue? Thank you in advance.
Add this
import tensorflow._api.v2.compat.v1 as tf
tf.disable_v2_behavior()
@@mathkernel5136 thanks this worked!
@@mathkernel5136 Thanks!
@@mathkernel5136 Sir you are amazing!
Thanks for the most simplest and least intimidating video on the concepts and implementation ever. The concepts are crystal clear now. Please help in explaining how to save and then reload the same model again given that there is an Encoder/Decoder and Custom Layer as well. If I save the vae and load it back I face an error as - ValueError: Unknown layer: CustomLayer. Please help. Thanks
Thanks for this excellent tutorial. How do we write the samples of a certain distribution say (-3, 3) to a new folder rather than displaying on the figure? Pls include that code statement as well. Thanks in advance.
excellent video for the subject. Your effort is greatly appreciated.
Thank you
Thank you for the informative implementation. I am trying to use VAE for image-inpainting (starting point). I feed the network with incomplete images. I am not sure how to adapt this implementation such that loss is computed against the complete image, not the masked/incomplete ones. any leads?
First of all, thank you for your videos. I followed your model, and I am trying to tweak this VAE for anomaly detection. I trained using only 5s, and I want to see if it can detect 4s as an anomaly, for example. I tried prediction = vae.predict(sample), but the prediction and sample are identical every time! Something must be wrong because I expect that there should be a random sampling of the latent space for every prediction, thus shouldn't there at least be small variations? Could this be a biproduct of setting loss=None in the compiler and instead having the loss function defined in a custom layer?
when i run fit, i ran into an error of
TypeError: You are passing KerasTensor(type_spec=TensorSpec(shape=(), dtype=tf.float32, name=None), name='tf.math.reduce_sum_3/Sum:0', description="created by layer 'tf.math.reduce_sum_3'"), an intermediate Keras symbolic input/output, to a TF API that does not allow registering custom dispatchers, such as `tf.cond`, `tf.function`, gradient tapes, or `tf.map_fn`. Keras Functional model construction only supports TF API calls that *do* support dispatching, such as `tf.math.add` or `tf.reshape`. Other APIs cannot be called directly on symbolic Kerasinputs/outputs. You can work around this limitation by putting the operation in a custom Keras layer `call` and calling that layer on this symbolic input/output.
is there a way to get rid of class CustomLayer(keras.layers.Layer) and write in simple python with a funtion that calculates the sum of the 2 loss terms ? The coode that follows does NOT work:
def vae_loss(x, z_decoded):
x = K.flatten(x)
z_decoded = K.flatten(z_decoded)
recon_loss = keras.metrics.binary_crossentropy(x, z_decoded)
kl_loss = -5e-4 * K.mean(1 + z_sigma - K.square(z_mu) - K.exp(z_sigma), axis=-1)
return K.mean(recon_loss + kl_loss)
y = decoder(z)
vae = Model(input_img, y, name='vae')
vae.compile(optimizer='adam', loss=vae_loss)
vae.fit(x_train, None, epochs = 10, batch_size = 32, validation_split = 0.2)
Please add one more video on VAE for Categorial Data (using categorical reparameterization with gumbel-softmax)
Thanks for the great Video! P.S: Did someone find the Movistar dataset, that he talks about in the end? :)
Hi Sir. Superb explanation from the start. I really appreciate it. By the way, have you try this VAE model with the movie star dataset that you mention in the last part of this video. Really looking forward for the explanation video on it
Hello sir and where is the precision of the model?
Sir i have a little concussion...
Mean layer and variance layer are connected to the same layer then how mean layer computes mean and how variance layer computes variance?
Is the latent space one-dimentional or two-dimentional, like the data or something else?
How can I generate a sample from the underlying prior instead of a random sample vector?
Hi Sreeni, this video was really helpful. But, I am having tough time understanding, that why you used, mu + exp(sigma/2) * epsilon. The expression was mu + sigma * epsilon
@@samedbey3548 Okay makes sense, then what is the divided by 2 for?
Thanks for the video
my data is a CSV file, and my vae is multi-input, what should I change in the customlayer() class or in this line "y = CustomLayer()([[x_in,y_in,z_in], z_decoded])" so it can work perfectly?
thank you in advance sir
Hi, such a helpful video, thank you Sreeni!
I was wondering, suppose i'm working on a different data and the latent vector dimension is say 128 instead of 2, how do we visualize and figure out each value of the sample_vector to generate data then?
t-SNE
thanks alot for this explanation.
i am having a small error while trying to run the code.
the fit step:
vae.fit(x_train, None, epochs = 5, batch_size = 32, validation_split = 0.2)
the error:
TypeError: You are passing KerasTensor(type_spec=TensorSpec(shape=(), dtype=tf.float32, name=None), name='tf.math.reduce_sum_2/Sum:0', description="created by layer 'tf.math.reduce_sum_2'"), an intermediate Keras symbolic input/output, to a TF API that does not allow registering custom dispatchers, such as `tf.cond`, `tf.function`, gradient tapes, or `tf.map_fn`. Keras Functional model construction only supports TF API calls that *do* support dispatching, such as `tf.math.add` or `tf.reshape`. Other APIs cannot be called directly on symbolic Kerasinputs/outputs. You can work around this limitation by putting the operation in a custom Keras layer `call` and calling that layer on this symbolic input/output.
please help.
I'm getting this error:
TypeError: You are passing KerasTensor(type_spec=TensorSpec(shape=(), dtype=tf.float32, name=None), name='tf.math.reduce_sum_1/Sum:0', description="created by layer 'tf.math.reduce_sum_1'"), an intermediate Keras symbolic input/output, to a TF API that does not allow registering custom dispatchers, such as `tf.cond`, `tf.function`, gradient tapes, or `tf.map_fn`. Keras Functional model construction only supports TF API calls that *do* support dispatching, such as `tf.math.add` or `tf.reshape`. Other APIs cannot be called directly on symbolic Kerasinputs/outputs. You can work around this limitation by putting the operation in a custom Keras layer `call` and calling that layer on this symbolic input/output.
what should I do?
Hi, were you able to solve this error? I am also getting same one
Same problem here.
Me too. Pls let us know if you able to solve it
The code does not work =(
Amazing video!, love it🎉
Which version of keras is it???
Great explanation! How do we know which file from the github references this video? I can't find it by the Title of the files, and there are LOTs of files in the Github.
This is exactly why I numbered my videos and corresponding files on Github.
Beautifully explained !
Glad it was helpful!
Very detailed explanation! One thing I'm not very clear is that why you said y is the reconstructed image? Shouldn't it be z_decoded?
Yes, if you want the final VAE model to return the decoded image as output, then call(self,inputs) should return z_decoded instead of x. This took me awhile to realize, so I hope this helps! This video was tremendously helpful otherwise!
Thank you very much this was very useful and clear!!! Could you make a video on Beta VAE? It would be very interesting for anyone working with this models
Thanks that was a great expectation, but please help I can't train the model, as it's showing unhashable error when I applied custom layer for loss, and also when I created the loss function used by you and passed it in model.compile loss becomes null, please help in that I have wasted one whole day l, but couldn't detect the problem
How to save this model?
great job man
I did not get lambda function
This one is amazing great content
If anyone is getting a type error when trying to run the code in google colab try this,
Create a new code block and run these two lines
!pip install tensorflow==1.13.2
!pip install q keras==2.0.8
then go to -> Runtime -> Restart Runtime and try to run the code again and it should work
can you tell us what should be changed to work in latest tensorflow version??
Great job , very analytical explanation. I am tryin to run it for my model with a target y on fit method but I can't. Any suggestions? Thanks!
I am facing the same problem, did you find any solution?
I have been trying to implement VAE and this is the best video I have found. I followed each and every step but there is some weird error and many people are facing the same error who have watched your video. Can you help me with it?
Is it this error?
TypeError: Cannot convert a symbolic Keras input/output to a numpy array. This error may indicate that you're trying to pass a symbolic value to a NumPy call, which is not supported. Or, you may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model.
@@blasttrash yes! This is the error!
Great explanation. Thanks.
Glad it was helpful!
Awsm...sir thanks alot....
Most welcome
my scatterplot of the latent space is never symmetrical, yaxis: (-4,0) and xaxis: (0,5), and i had (-4,0) and (-4,0) as well one time. does anybody know what my error could be?
you earnt my sub with this video. thank you
You are awesome! 😀
You too!!
thank you for the great tutorial !!
You are welcome!
Thanks!!
Please can anyone tell how to save and reload this model?
great video
Thanks!
I would like to thank you for your great work! You inspire many young programmers to learn more about machine learning!
When I try to execute your code in my local GPU, I see the following error:
Resource exhausted: OOM when allocating tensor with shape[32,32,29,29] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc.
I tried to decrease batch size to 1 and still have an OOM error. Does anybody know what should I do next?
You are getting out of memory error. Try reducing batch size or resizing images to smaller size. OOM error is common with GPU with small memory, usually below 4GB.
Thanks so much sir.
Very good video on VAE's
Glad you think so!
Sir could you please make a video on Test Time Augmentation please ...
GREAT!!!!!
What do Conv[0] , Conv[1],Conv[2] mean?
I don't think there is anything like Conv[0] in the code. In case you are referring to conv_shape[0], it is explained in line 72 of the code. It is the shape of conv to be provided to decoder.
@@DigitalSreeni Yes - that's what I meant. THank you
Thanks sir
For me it' s not intuitive why the .fit method uses (X_train,None) when it should be (X_train,X_train ) . Btw great explanation overall
In a standard autoencoder, the input data is used both as the input and target for training. This means that the autoencoder tries to reconstruct the input data as closely as possible. The .fit method typically takes (X_train, X_train) format.
VAE is a specific type of autoencoder that adds a constraint to the latent space by using probabilistic techniques. The objective of a VAE is not only to reconstruct the input data but also to learn a probabilistic representation of the data in the latent space. This latent space representation is then used to generate new data points by sampling from the learned distribution. So, in the context of Keras (or other deep learning frameworks), when fitting a VAE model, the .fit method often takes (X_train, None) instead of (X_train, X_train). The reason for this is that in a VAE, the model's output consists of both the reconstructed data and the parameters representing the latent space distribution. The None value is passed as the target because the target for the regularization loss is not the input data (X_train) but rather the desired shape of the latent space distribution (typically a standard normal distribution).
@@DigitalSreeni Appreciate your explanation sir , really helpfull. thank you so much
FYI, I was only able to get this example to work with keras 2.0.8 and. tensorflow 1.4 in python 3.5. I tried it in. python 3.8 with keras 2.4.3 and tensorflow would crash on the training part.
Well, I am glad you found the version where this works for you.
Is the input dimension? Are you using binary categorizing?
Thanks
Thank you very much.
Can anyone please explain this KL loss equation kl_loss = -5e-4 * K.mean(1 + z_sigma - K.square(z_mu) - K.exp(z_sigma), axis=-1)
Merci !
thanks