You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""Class providing the functionality for a vanilla CNN architecture on `CIFAR-10`.
24
+
25
+
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 10-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``.
26
+
27
+
Basis data augmentation (random crop, left-right flip, lighting augmentation) is done on the training images.
28
+
29
+
A suggested training settings is for ``100`` epochs with a batch size of ``128``.
30
+
31
+
Args:
32
+
batch_size (int): Batch size of the data points. Defaults to ``128``.
33
+
weight_decay (float): Weight decay factor. In this model weight decay is applied to the weights, but not the biases. Defaults to ``0.002``.
34
+
35
+
Attributes:
36
+
data_loading (deepobs.data_loading): Data loading class for `CIFAR-10`, :class:`.cifar10_input.data_loading`.
37
+
losses (tf.Tensor): Tensor of size ``batch_size`` containing the individual losses per data point.
38
+
accuracy (tf.Tensor): Tensor containing the accuracy of the model.
39
+
train_init_op (tf.Operation): A TensorFlow operation to be performed before starting every training epoch.
40
+
train_eval_init_op (tf.Operation): A TensorFlow operation to be performed before starting every training eval epoch.
41
+
test_init_op (tf.Operation): A TensorFlow operation to be performed before starting every test evaluation phase.
Copy file name to clipboardExpand all lines: deepobs/cifar10/cifar10_input.py
+89-24Lines changed: 89 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,37 @@
9
9
10
10
11
11
classdata_loading:
12
+
"""Class providing the data loading functionality for the CIFAR-10 data set.
13
+
14
+
Args:
15
+
batch_size (int): Batch size of the input-output pairs. No default value is given.
16
+
data_augmentation (bool): Switch to turn basic data augmentation on or off while training. Defaults to ``true``.
17
+
18
+
Attributes:
19
+
batch_size (int): Batch size of the input-output pairs.
20
+
data_augmentation (bool): Switch to turn basic data augmentation on or off while training.
21
+
train_eval_size (int): Number of data points to evaluate during the `train eval` phase. Currently set to ``10000`` the size of the test set.
22
+
D_train (tf.data.Dataset): The training data set.
23
+
D_train_eval (tf.data.Dataset): The training evaluation data set. It is the same data as `D_train` but we go through it separately.
24
+
D_test (tf.data.Dataset): The test data set.
25
+
phase (tf.Variable): Variable to describe which phase we are currently in. Can be "train", "train_eval" or "test". The phase variable can determine the behaviour of the network, for example deactivate dropout during evaluation.
26
+
iterator (tf.data.Iterator): A single iterator for all three data sets. We us the initialization operators (see below) to switch this iterator to the data sets.
27
+
X (tf.Tensor): Tensor holding the CIFAR-10 images. It has dimension `batch_size` x ``32`` (image size) x ``32`` (image size) x ``3`` (rgb).
28
+
y (tf.Tensor): Label of the CIFAR-10 images. It has dimension `batch_size` x ``10`` (number of classes).
29
+
train_init_op (tf.Operation): A TensorFlow operation to be performed before starting every training epoch. It sets the `phase` variable to "train" and initializes the iterator to the training data set.
30
+
train_eval_init_op (tf.Operation): A TensorFlow operation to be performed before starting every training eval phase. It sets the `phase` variable to "train_eval" and initializes the iterator to the training eval data set.
31
+
test_init_op (tf.Operation): A TensorFlow operation to be performed before starting every test evaluation phase. It sets the `phase` variable to "test" and initializes the iterator to the test data set.
"""Creates a data set from a pattern of the images and label files.
194
+
195
+
Args:
196
+
binaries_fname_pattern (str): Pattern of the ``,bin`` files containing the images and labels.
197
+
batch_size (int): Batch size of the input-output pairs.
198
+
crop_size (int): Crop size of each image. Defaults to ``32``.
199
+
per_image_standardization (bool): Switch to standardize each image to have zero mean and unit norm. Defaults to ``True``.
200
+
random_crop (bool): Switch if random crops should be used. Defaults to ``False``.
201
+
pad_before_random_crop (int): Defines the added padding before a random crop is applied. Defaults to ``0``.
202
+
random_flip_left_right (bool): Switch to randomly flip the images horizontally. Defaults to ``False``.
203
+
lighting_augmentation (bool): Switch to use random brightness, saturation and contrast on each image. Defaults to ``False``.
204
+
one_hot (bool): Switch to turn on or off one-hot encoding of the labels. Defaults to ``True``.
205
+
shuffle (bool): Switch to turn on or off shuffling of the data set. Defaults to ``True``.
206
+
shuffle_buffer_size (int): Size of the shuffle buffer. Defaults to ``10000`` the size of the `test` and `train eval` data set, meaning that they will be completely shuffled.
207
+
num_prefetched_batches (int): Number of prefeteched batches, defaults to ``3``.
208
+
num_preprocessing_threads (int): The number of elements to process in parallel while applying the image transformations. Defaults to ``8``.
209
+
data_set_size (int): Size of the data set to extract from the images and label files. Defaults to ``-1`` meaning that the full data set is used.
210
+
211
+
Returns:
212
+
tf.data.Dataset: Data set object created from the images and label files.
0 commit comments