# Deep Machine Learning for Path Length Characterization Using Acoustic Diffraction
## 2 Materials and Methods
### Convolutional Neural Networks
#### 2.3.3 Phase Model  
The phase CNN uses a similar ten-layer design to the amplitude model. The model trains on the SDFTs representing the change in phase. Preprocessing analysis showed low and varying correlations between the lateral locations hint  
Figure 10: The Model Architecture for the Amplitude CNN.  
relationship. The model design includes an input layer, four convolutional layers, two max-pooling layers, a flattening layer, two fully connected layers, and an output layer. All input data (pixels and acoustic path lengths) are normalized between zero and one. This section details the layers of this model.  
**Input**: As with the Amplitude model, this CNN takes in 51 \(\times\) 17 \(\times\) 1 images in the form of SDFTs. In this case, the SDFTs represent transfer function phase data. Again, the images are 51 pixels tall, 17 pixels wide, and in grayscale and normalized between 0 and 1.  
**Convolution Layer 1 & 2**: The first two convolution layers apply 64 kernels which are sized 7 \(\times\) 7 and use a stride of 1 with the same size padding. The same size padding will pad 0's around the exterior of the image so that the kernel can be applied to all pixels of the image without reducing the size of the image. This is important in this model as the images are very narrow, but the relationships are fairly complex.  
**Max Pooling 1**: The first two convolution layers are followed by a max pooling layer with a kernel-sized 2 \(\times\) 2. The use of such a max pooling layer allows us to reduce the dimensionality of the model while maintaining the most important features from each kernel. Max pooling also increases the generalizations made by the model to reduce noise in the image.  
**Convolution Layer 3**: This convolution layer applies 96 5 \(\times\) 5 kernels with a stride of 1 and the same size padding.  
**Convolution Layer 4**: This convolution layer applies 96 kernels which are sized 5 \(\times\) 5 and use a stride of 1 with the same size padding.  
**Max Pooling 2**: The second two convolution layers are followed by a max pooling layer with a kernel sized 2 \(\times\) 2 to once again reduce the dimensionality and allow generalization of the extracted features.  
**Flattening**: Flattening layers take the resulting feature maps from the final max pooling layer and flatten them into a feature vector to allow connection to a dense layer. Immediately after flattening, 40% of the features are dropped to avoid overfitting the features in the feature vector.  
**Fully Connected Layers**: The flattening layer connects to a fully connected layer with only 230 nodes.  
**Output**: The fully connected features are connected to a single node which uses a regression with the ReLU function to determine the acoustic path length. This function works best for the Phase model as the relationship between the transfer function amplitude and the normalized acoustic path length is a more linear relationship which is increasing between 0 and 1.  
The architecture for the phase model is depicted in Figure 11.  
Figure 11: The Model Architecture for Phase CNN.  
Both models use ReLU as the activation function in the convolution layers. ReLU is the standard choice of activation function for convolution layers, as this activation function sets all negative neurons to 0. This has the effect of removing black pixels and replacing them with gray pixels, which helps to reduce contrast in the features. Each model is also optimized using an Adam optimizer with a learning rate of 0.0001. The Adam optimizer was selected as it can rapidly optimize performance by quickly seeking out the local minima while tuning the weights of the model. The learning rate of 0.0001 with these models gave the best trade-off of training time and model performance. The models also use mean square error as the loss function, which is fairly standard in regression models. Finally, the models train using a batch size of 128 for 20 epochs or until the loss begins to stabilize.