MNIST 2c2d

class deepobs.mnist.mnist_2c2d.set_up(batch_size=128, weight_decay=None)[source]

Class providing the functionality for a vanilla CNN architecture adapted from the TensorFlow tutorial on MNIST.

It consists of two convolutional layers with ReLU activations, each followed by max-pooling, followed by one fully-connected layer with ReLU activations and a 10-unit output layer with softmax. The model uses cross-entroy loss and no regularization. The weight matrices are initialized with truncated normal (stddev= 0.05) and the biases are initialized to 0.05.

Parameters:
  • batch_size (int) -- Batch size of the data points. Defaults to 128.
  • weight_decay (float) -- Weight decay factor. In this model there is no weight decay implemented. Defaults to None.
data_loading

Data loading class for MNIST, mnist_input.data_loading.

Type:deepobs.data_loading
losses

Tensor of size batch_size containing the individual losses per data point.

Type:tf.Tensor
accuracy

Tensor containing the accuracy of the model.

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
bias_variable(name, shape, init_val)[source]

Creates a bias variable of given shape and initialized to a given value.

Parameters:
  • name (str) -- Name of the bias variable.
  • shape (list) -- Dimensionality of the bias variable.
  • init_val (float) -- Initial value of the bias variable.
Returns:

Bias variable.

Return type:

tf.Variable

conv2d(x, W, stride=1, padding='SAME')[source]

Creates a two dimensional convolutional layer on top of a given input.

Parameters:
  • x (tf.Variable) -- Input to the layer.
  • W (tf.Variable) -- Weight variable of the convolutional layer.
  • stride (int) -- Stride of the convolution. Defaults to 1.
  • padding (str) -- Padding of the convolutional layers. Can be SAME or VALID. Defaults to SAME.
Returns:

Output after the convolutional layer.

Return type:

tf.Variable

get()[source]

Returns the losses and the accuray of the model.

Returns:Tupel consisting of the losses and the accuracy.
Return type:tupel
max_pool_2x2(x)[source]

Creates a 2 by 2 max pool layer on top of a given input.

Parameters:x (tf.Variable) -- Input to the layer.
Returns:Output after the max pool layer.
Return type:tf.Variable
set_up(weight_decay)[source]

Sets up the test problem.

Parameters:weight_decay (float) -- Weight decay factor. In this model there is no weight decay implemented.
Returns:Tupel consisting of the losses and the accuracy.
Return type:tupel
weight_variable(name, shape)[source]

Creates a weight variable, initialized by a truncated normal of stdev= 0.05.

Parameters:
  • name (str) -- Name of the weight variable.
  • shape (list) -- Dimensionality of the weight variable.
Returns:

Weight variable.

Return type:

tf.Variable