SVHN 3c3d

class deepobs.svhn.svhn_3c3d.set_up(batch_size=128, weight_decay=0.002)[source]

Class providing the functionality for a vanilla CNN architecture on SVHN.

It consists of three convolutional layers with ReLU activations, each followed by max-pooling, followed by two fully-connected layer with ReLU activations and a 100-unit output layer with softmax. The model uses cross-entroy loss. A weight decay is used on the weights (but not the biases) which defaults to 0.002. The weight matrices are initialized using the Xavier-Initializer and the biases are initialized to 0.

Parameters:
  • batch_size (int) -- Batch size of the data points. Defaults to 128.
  • weight_decay (float) -- Weight decay factor. In this model weight decay is applied to the weights, but not the biases. Defaults to 0.002.
data_loading

Data loading class for SVHN, svhn_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='VALID')[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 VALID.
Returns:

Output after the convolutional layer.

Return type:

tf.Variable

conv_filter(name, shape)[source]

Creates a convolutional filter matrix, initialized by the Xavier-initializer.

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

Filter variable.

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_3x3(x)[source]

Creates a 3 by 3 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 weight decay is applied to the weights, but not the biases.
Returns:Tupel consisting of the losses and the accuracy.
Return type:tupel
weight_matrix(name, shape)[source]

Creates a weight matrix, initialized by the Xavier-initializer.

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

Weight variable.

Return type:

tf.Variable