# Transfer Learning Analysis for Subvisible Particle Flow Imaging of Pharmaceutical Formulations
## 2 Materials and Methods
### Data Analyses
#### 2.3.2 Convolutional Neural Networks  
Our work focused on classifying seven classes of particles by training VGG16 pre-trained on ImageNet. VGG16 [26] was developed by [PERSON] and [PERSON] from the Visual Geometry Group (VGG) at the University of Oxford, and won first place in the 2014 ILSVRC object-recognition challenge. Its main objective is to improve the depth of the neural network while following the basic structure of AlexNet to achieve better performance. Specifically, it uses several consecutive 3 \(\times\) 3 convolutional kernels instead of the larger convolutional kernels (11 \(\times\) 11, 7 \(\times\) 7, and 5 \(\times\) 5) used in AlexNet, as more convolutional layers can help to extract more abstract higher-order features with fewer parameters. The structure of a CNN consists of three parts: a convolutional layer, a pooling layer, and a fully connected layer. For convolution, after the image is input as a matrix into the CNN, the image matrix is passed through various filters to generate different feature maps, thereby obtaining different image features. For example, the filters of the first convolutional layer typically correspond to the edge and color block information of the image. As the input of each convolutional layer is the output of the previous convolutional layer, filters located deeper in the network can extract more complex morphological features and increasingly abstract visual concepts. The purpose of the pooling layer is to downsample the feature maps, which can reduce the number of elements in the maps to be processed and allow successive convolutional layers to have increasingly larger observation windows, thereby introducing a hierarchical structure of spatial filters. The fully connected layer plays the role of a classifier in the CNN, where the representatives of the convolutional and pooling layers map the input image to the feature space, and the fully connected layer maps these features to the sample-labeling space. The VGG16 used in this study contained 13 convolutional layers, 5 max-pooling layers, and 3 fully connected layers. Alternatively, it consisted of a convolution base with a classifier. During training, the CNN took the images in the training set as the input and obtained the probability of the images corresponding to each category through the forward propagation process. It then obtained the loss function value of the output layer according to the image labels, calculated the gradient of the error on each weight in the network using back propagation, and updated the values/weights of all filters using the gradient descent method to minimize the loss function value. This process was repeated during training. After training, the network classified images that were not included. This study used two methods to train the CNN. The first used VGG16 pre-trained on ILSVRC-2012, a subset of ImageNet, which is a large dataset containing 1.4 million labeled images with 1000 different classes. The data size of this dataset is sufficiently large and general and usually represents natural images. As shown in Figure 1, we used the pre-trained convolutional base of VGG16 (containing 13 convolutional layers and 5 max-pooling layers) with a final feature map shape of \(4\times 4\times 512\). We added a three-layer densely connected classifier to this feature to match our particle classification requirements. We froze the parameters in the convolutional base during training, and trained only the classifier. One main advantage of using transfer learning is that it trains only a small part of the network, resulting in a faster learning process than that of training the entire network. This reduces the risk of overfitting by reducing many training parameters, and smaller datasets can be used for transfer learning, avoiding the risk of overfitting by directly training small datasets. In another approach, we used the same network structure, but initialized all layers with random parameters and did not freeze any layers, thus training a CNN from scratch.