Transfer Learning Alexnet.ipynb - Colaboratory
Transfer Learning Alexnet.ipynb - Colaboratory
ipynb - Colaboratory
alex1
ReLU-based deep convolutional networks are trained several times faster than tanh and sigmoid-
based networks. The following figure shows the number of iterations for a four-layer
convolutional network based on CIFAR-10 that reached 25% training error in tanh and ReLU:
alex1
After using ReLU f (x) = max (0, x), you will find that the value after the activation function has no
range like the tanh and sigmoid functions, so a normalization will usually be done after ReLU,
and the LRU is a steady proposal (Not sure here, it should be proposed?) One method in
neuroscience is called "Lateral inhibition", which talks about the effect of active neurons on its
surrounding neurons.
alex1
3. Dropout
Dropout is also a concept often said, which can effectively prevent overfitting of neural networks.
Compared to the general linear model, a regular method is used to prevent the model from
overfitting. In the neural network, Dropout is implemented by modifying the structure of the
neural network itself. For a certain layer of neurons, randomly delete some neurons with a
defined probability, while keeping the individuals of the input layer and output layer neurons
unchanged, and then update the parameters according to the learning method of the neural
network. In the next iteration, rerandom Remove some neurons until the end of training.
alex1
In deep learning, when the amount of data is not large enough, there are generally 4 solutions:
Data augmentation- artificially increase the size of the training set-create a batch
of "new" data from existing data by means of translation, flipping, noise
adding a regular term after the Loss Function , the overfitting can be suppressed.
The disadvantage is that a need is introduced Manually adjusted hyper-parameter.
Dropout- also a regularization method. But different from the above, it is achieved
by randomly setting the output of some neurons to zero
import tensorflow as tf
tf.__version__
'2.2.0'
https://colab.research.google.com/drive/1RdWJDFMqC0DWAQMNyXduPe-ySuL-odUx#printMode=true 2/5
2/12/24, 8:24 AM Transfer Learning Alexnet.ipynb - Colaboratory
import tensorflow.keras
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Activation, Dropout, Flatten,\
Conv2D, MaxPooling2D,BatchNormalization
# Batch Normalisation
model.add(BatchNormalization())
# Output Layer
model.add(Dense(17))
model.add(Activation('softmax'))
model.summary()
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d (Conv2D) (None, 54, 54, 96) 34944
_________________________________________________________________
activation (Activation) (None, 54, 54, 96) 0
_________________________________________________________________
max_pooling2d (MaxPooling2D) (None, 27, 27, 96) 0
_________________________________________________________________
batch_normalization (BatchNo (None, 27, 27, 96) 384
_________________________________________________________________
conv2d_1 (Conv2D) (None, 17, 17, 256) 2973952
_________________________________________________________________
activation_1 (Activation) (None, 17, 17, 256) 0
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 8, 8, 256) 0
_________________________________________________________________
batch_normalization_1 (Batch (None, 8, 8, 256) 1024
_________________________________________________________________
conv2d_2 (Conv2D) (None, 6, 6, 384) 885120
_________________________________________________________________
activation_2 (Activation) (None, 6, 6, 384) 0
_________________________________________________________________
batch_normalization_2 (Batch (None, 6, 6, 384) 1536
_________________________________________________________________
conv2d_3 (Conv2D) (None, 4, 4, 384) 1327488
_________________________________________________________________
https://colab.research.google.com/drive/1RdWJDFMqC0DWAQMNyXduPe-ySuL-odUx#printMode=true 4/5
2/12/24, 8:24 AM Transfer Learning Alexnet.ipynb - Colaboratory
activation_3 (Activation) (None, 4, 4, 384) 0
_________________________________________________________________
batch_normalization_3 (Batch (None, 4, 4, 384) 1536
_________________________________________________________________
conv2d_4 (Conv2D) (None, 2, 2, 256) 884992
_________________________________________________________________
activation_4 (Activation) (None, 2, 2, 256) 0
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 1, 1, 256) 0
_________________________________________________________________
batch_normalization_4 (Batch (None, 1, 1, 256) 1024
_________________________________________________________________
flatten (Flatten) (None, 256) 0
_________________________________________________________________
dense (Dense) (None, 4096) 1052672
_________________________________________________________________
activation_5 (Activation) (None, 4096) 0
_________________________________________________________________
dropout (Dropout) (None, 4096) 0
_________________________________________________________________
batch_normalization_5 (Batch (None, 4096) 16384
https://colab.research.google.com/drive/1RdWJDFMqC0DWAQMNyXduPe-ySuL-odUx#printMode=true 5/5