In the field of machine learning, an activation function is a key component that introduces non-linearity into a model, enabling it to learn and represent complex patterns in the data. The choice of an activation function can significantly impact the performance of a model, and various types of activation functions have been developed to cater to different needs and requirements.
In the context of the FD module of the Siamese network, the role of the Hard tanh activation function is essential in differentiating foreground features from background features. The Hard tanh function is a modified version of the hyperbolic tangent (tanh) function, which is a common activation function used in various deep learning models.
The Hard tanh function is designed to map the input to the range (-1, 1), making it particularly suitable for this task. By mapping the background feature Ymax,iKi to a range that is not limited by probability, the Hard tanh function helps in better removing redundant information from . This is crucial for increasing the gap between the foreground and background features, thereby expanding the inter-class distance.
The Hard tanh function is defined as:
\begin{equation}
Hardtanh(x)=\begin{cases}
-1, & \text{if } x<-2 \
x, & \text{if } -2 \leq x \leq 2 \
1, & \text{if } x>2
\end{cases}
\end{equation}
As can be seen from the definition, the Hard tanh function is a piecewise linear function that remains constant for input values outside the range (-2, 2). This helps in mapping the background features to a range (-1, 1), which is beneficial for the purpose of differentiating foreground and background features.
After applying the Hard tanh activation function to the background features, the next step is to train the predicted value PiKi of the background to tend towards -1. This is achieved by using the mean square error between the predicted and the pseudo target -1 as the stage loss function , as defined in equation (\ref{equation8}):