Single Skip¶
This is a use case of DEATF where a skip CNN is used.
This is a classification problem with fashion MNIST dataset. This example is similar to the cnn_class.py file; but, in this case the CNN used has skips in its structure. Those skips are conections that are made from a layer with layers that are after it.
-
class
single_skip.SkipCNN(network_descriptor)¶ Bases:
deatf.network.CNNThis network inherits from CNN that in turn inherits from Network (what SkipCNN also does). The parameters are the same as the CNN, it only rewrites the building function. In it a new parameter is added, that is the skip added to the network from the beginig to the selected layer, that is the difference.
- Parameters
network_descriptor – Descriptor of the CNN.
-
building(x, skip)¶ Given a TensorFlow layer, this functions continues adding more layers of a SkipCNN.
- Parameters
x – A layer from TensorFlow.
skip – Number of the layer it has to do the skip into. If the number is greater than the number of layers, it will be calculated and reasigned a new value.
- Returns
The layer received from parameter with the SkipCNN concatenated to it.
-
single_skip.eval_cnn(nets, train_inputs, train_outputs, batch_size, iters, test_inputs, test_outputs, hypers)¶ Creates the model formed by the SkipCNN that has been created and then a MLP is sequenetialy added with a flatten and a dense layer in between. That model is trained by using cross entropy function and the final evaluation is done with the accuracy error.
- Parameters
nets – Dictionary with the networks that will be used to build the final network and that represent the individuals to be evaluated in the genetic algorithm.
train_inputs – Input data for training, this data will only be used to give it to the created networks and train them.
train_outputs – Output data for training, it will be used to compare the returned values by the networks and see their performance.
batch_size – Number of samples per batch are used during training process.
iters – Number of iterations that each network will be trained.
test_inputs – Input data for testing, this data will only be used to give it to the created networks and test them. It can not be used during training in order to get a real feedback.
test_outputs – Output data for testing, it will be used to compare the returned values by the networks and see their real performance.
hypers – Hyperparameters that are being evolved and used in the process.
- Returns
Accuracy error obtained with the test data that evaluates the true performance of the network.