How to do it...

In this section, we will build a VAE model so that we can reconstruct fashion MNIST images. Let's start by defining the network parameters of our VAE:

  1. First, we need to define some variables that will set the network parameters, batch size, input dimension, latent dimension, and the number of epochs:
# network parametersbatch_size <- 100Linput_dim <- 784L
latent_dim <- 2Lepochs <- 10
  1. Let's define the input layer and the hidden layer of the encoder part of the VAE:
# VAE input layer and hidden layer encoderinput <- layer_input(shape = c(input_dim))x <- input %>% layer_dense(units = 256, activation = "relu")
  1. Now, we configure the dense layers that represent the mean and log of the standard deviation of the latent distribution: ...

Get Deep Learning with R Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.