Fashion-MNIST VAE¶
-
class
deepobs.fmnist.fmnist_vae.set_up(batch_size=64, n_latent=8, weight_decay=None)[source]¶ Class providing the functionality for a Variational Autoencoder (VAE) adapted from here on Fashion-MNIST.
Parameters: - batch_size (int) -- Batch size of the data points. Defaults to
64. - n_latent (int) -- Size of the latent space of the encoder. Defaults to
8. - weight_decay (float) -- Weight decay factor. In this model there is no weight decay implemented. Defaults to
None.
-
data_loading¶ Data loading class for Fashion-MNIST,
fmnist_input.data_loading.Type: deepobs.data_loading
-
losses¶ Tensor of size
batch_sizecontaining the individual losses per data point.Type: tf.Tensor
-
accuracy¶ Tensor containing the accuracy of the model. As there is no accuracy when the loss function is given directly, we set it to
0.Type: tf.Tensor
-
train_init_op¶ A TensorFlow operation to be performed before starting every training epoch.
Type: tf.Operation
-
train_eval_init_op¶ A TensorFlow operation to be performed before starting every training eval epoch.
Type: tf.Operation
-
test_init_op¶ A TensorFlow operation to be performed before starting every test evaluation phase.
Type: tf.Operation
-
decoder(sampled_z, phase, n_latent)[source]¶ The decoder for the VAE. It uses two dense layers, followed by three deconvolutional layers (each with dropout=
0.8) a final dense layer. The dense layers use the leaky ReLU activation (except the last one, which uses softmax), while the deconvolutional ones use regular ReLU.Parameters: - sampled_z (tf.Variable) -- Sampled
zfrom the encoder of the sizen_latent. - phase (tf.Variable) -- Phase variable, determining if we are in training or evaluation mode.
- n_latent (int) -- Size of the latent space of the encoder. Defaults to
8.
Returns: A tensor of the same size as the original images (
28by28).Return type: tf.Variable
- sampled_z (tf.Variable) -- Sampled
-
encoder(X, phase, n_latent)[source]¶ Encoder of the VAE. It consists of three convolutional and one dense layers. The convolutional layers use the leaky ReLU activation function. After each convolutional layer dropout is appleid with a keep probability of
0.8.Parameters: - X (tf.Variable) -- Input to the encoder.
- phase (tf.Variable) -- Phase variable, determining if we are in training or evaluation mode.
- n_latent (int) -- Size of the latent space of the encoder. Defaults to
8.
Returns: Output of the encoder,
z, the mean and the standard deviation.Return type: tupel
-
generate(sess, sampled_z=None)[source]¶ Function to generate images using the decoder. Images are ploted directly.
Parameters: - sess (tf.Session) -- A TensorFlow session.
- sampled_z (tf.Variable) -- Sampled
zwith dimensionslatent sizetimesnumber of examples. Defaults toNonewhich uses five randomly sampledzfrom a normal with stddev =1.0.
-
get()[source]¶ Returns the losses and the accuray of the model.
Returns: Tupel consisting of the losses and the accuracy. Return type: tupel
-
lrelu(x, alpha=0.3)[source]¶ Leaky ReLU activation function.
Parameters: - x (tf.Variable) -- Input to the activation function.
- alpha (float) -- Factor of the leaky ReLU. Defines how leaky it is. Defauylts to
0.3.
Returns: Output after the activation function.
Return type: tf.Variable
-
set_up(weight_decay=None, n_latent=8)[source]¶ Sets up the test problem.
Parameters: - weight_decay (float) -- Weight decay factor. In this model there is no weight decay implemented. Defaults to
None. - n_latent (int) -- Size of the latent space of the encoder. Defaults to
8.
Returns: Tupel consisting of the losses and the accuracy.
Return type: tupel
- weight_decay (float) -- Weight decay factor. In this model there is no weight decay implemented. Defaults to
- batch_size (int) -- Batch size of the data points. Defaults to