of the first flat hidden layer should besecond convolution layer } - ( { first convolution layer where the multiplication by follows from the fact that the second convolution layer has output channels having said thatthe flat_fts variable determines the number of output layers of the convolution block this number is used to define the size of the first hidden layer of the flat_layer block the rest of the hidden layers have neurons and we use the relu activation function for all layers finallynote that the forward method in the cnn class implements the forward pass define the network class cnn(nn module )def __init__ (self)super (cnn self__init__ (self cnn_layer nn sequential nn conv ( kernel_size = stride =( , ))nn relu (nn conv ( kernel_size = stride =( , ))nn relu (self flat_fts ((( - + - + ** * self flat_layer nn sequential nn linear (self flat_fts nn relu (nn linear ( nn relu (nn linear ( nn relu (nn linear ( )def forward (self )out self cnn_layer (xout out view (- self flat_fts out self flat_layer (outreturn out nextwe specify how the network will be trained we choose the device typenamelythe central processing unit (cpuor the gpu (if available)the number of training iterations (epochs)and the learning rate thenwe create an instance of the proposed convolution network and send it to the predefined device (cpu or gpunote how easily one can switch between the cpu or the gpu without major changes to the code in addition to the specifications abovewe need to choose an appropriate loss function and training algorithm herewe use the cross-entropy loss and the adam adaptive gradient algorithm once these parameters are setthe learning proceeds to evaluate the gradient of the loss function via the back-propagation algorithm