I'm following the introductory MIT Deep Learning course on Youtube and i've been stuck for a day now on this piece of code:
self.encoder = make_standard_classifier(num_encoder_dims) self.decoder = make_face_decoder_network() def encode(self, x): # encoder output encoder_output = self.encoder(x) # classification prediction y_logit = tf.expand_dims(encoder_output[:, 0], -1) # latent variable distribution parameters z_mean = encoder_output[:, 1:self.latent_dim+1] z_logsigma = encoder_output[:, self.latent_dim+1:] return y_logit, z_mean, z_logsigma
This is the encoder network in a VAE. I don't understand what is exaclty doing tf.expand_dims, is it adding a dimension to the encoder output? Or it also taking the value in encoder_output[:,0] and returning it?
The second question is about z_mean and z_logsigma. Why are they in those positions of the output? Shouldn't they be computed on it? The encoder is a standard one so no particular output, it has as last Layer a Dense one with 2*latent dim + 1 outputs.
This is the url to the code https://github.com/aamini/introtodeeplearning/blob/master/lab2/solutions/Part2_Debiasing_Solution.ipynb
I know it may be a trivial question but at the moment this is the very big difficulty i've found in this course. Thank you very much!