-
-
Notifications
You must be signed in to change notification settings - Fork 415
Convolutional Neural Networks
The aim is to design a simple convolutional Neural Network using TensorFlow. The tutorial is aimed to sketch a startup model to the the two following:
- Define an organization for the network architecture, training and evaluation phases.
- Provides a template framework for constructing larger and more complicated models.
Two simple convolutional layers`(each have max pooling) followed by two `fully-cnnected layers conisdered. The number of output units for the last fully-connected layer is equal to the number of classes becasue a softmax has been implemented for the classification task.
The source code is embedded in code folder.
The input format is HDF5 for this implemetation but it basically can be anything as long as it satisfies the shape properties. For each TRAIN and TEST data, there are attributes call cube and label. The cube is the data of the shape (Number_Samples,height,width,Number_Channels) and the label is of the form (Number_Samples,1) in which each row has the class label. The label matrix should be transform to the form of (Number_Samples,Number_Classes) for which each row is associated with a sample and all of the columns are zero except for the one which belongs to the class number. Method Reform_Fn does this in the begining.
As conventional procedure, updating the gradient is done with batches of the data. Moreover Batch Normalization has been implemented for each convolutional layer. No Batch Normalization is done for the fully-connected layers. For all the convolutional and fully-connected layers, the drop-out has been used with the same parameter however this parameter can be customized for each layer in the code. Traditional GradientDescentOptimizer has been used.
Cross-entropy loss function has been chosen for the cost of system. The definition is as follows:
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))
Instead the tf.nn.softmax_cross_entropy_with_logits on the unnormalized logits (i.e., softmax_cross_entropy_with_logits is called on tf.matmul(x, W) + b), this function computes the softmax activation internally which makes it more stable. It's good to take a look at the source code of TensorFlow for that however there is a traditional idea to overcome this problem which is add an epsilon number with the absolute value of y and take it as y.
Introduction
Inauguration
Basics
Machine Learning Basics
Neural Networks