Import matplotlib.pyplot as plt def plot_latent_space ( vae, n = 30, figsize = 15 ): # display a n*n 2D manifold of digits digit_size = 28 scale = 1.0 figure = np. update_state ( reconstruction_loss ) self. reduce_sum ( kl_loss, axis = 1 )) total_loss = reconstruction_loss + kl_loss grads = tape. binary_crossentropy ( data, reconstruction ), axis = ( 1, 2 ) ) ) kl_loss = - 0.5 * ( 1 + z_log_var - tf. ![]() ![]() GradientTape () as tape : z_mean, z_log_var, z = self. Mean ( name = "kl_loss" ) def metrics ( self ): return def train_step ( self, data ): with tf. Mean ( name = "reconstruction_loss" ) self. Model ): def _init_ ( self, encoder, decoder, ** kwargs ): super ( VAE, self ). ![]() Sampling (Sampling) (None, 2) 0 z_meanĬonv2d_transpose (Conv2DTran (None, 14, 14, 64) 36928Ĭonv2d_transpose_1 (Conv2DTr (None, 28, 28, 32) 18464Ĭonv2d_transpose_2 (Conv2DTr (None, 28, 28, 1) 289ĭefine the VAE as a Model with a custom train_stepĬlass VAE ( keras. Layer (type) Output Shape Param # Connected to
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |