# TD-DNN: A Time Decay-Based Deep Neural Network for Recommendation System
## 4 Proposed Methodology
### Constructing Deep Neural Network
#### 4.2.4 Training Process  
Our proposed deep learning model includes the data preprocessing step in the basic neural network architecture. The Deep Learning architectures compare the predicted ratings with the actual ones and constantly refine the target loss to achieve the final optimal fit. In the training of every neural network model, the loss function and optimizer are very important, which are described below:  
The loss function measures the difference between the actual output and the model's predicted output. Selecting an appropriate loss function is most important. There are mainly two types of loss function [11]: pointwise and pairwise loss function. The recommender systems problem is transformed into a multi-classification or regression problem using a pointwise loss function. In contrast, the problem is transformed into a binary classification problem using a pairwise loss function. The pointwise loss functions include classification  
Figure 2: Architecture of our Deep Neural Network model. and ordinal regression, whereas pairwise loss functions includes Bayesian Pairwise Ranking (BPR) [11] and Area Under the Curve (AUC). The proposed neural network model predicts the ratings, which is a regression problem. So, the binary cross and multi-class information are inappropriate for the model. We can employ squared, absolute, and any other common pointwise regression losses [68], but the Huber loss function is used to mitigate the issues of the squared and absolute loss functions. The drawback of the squared loss is that it is particularly susceptible to outliers, whereas the absolute loss function can provide a non-biased estimation of the arithmetic average. The Huber loss [11] is described as follows:  
\[Huber\ Loss= \begin{cases}\frac{1}{2}\times(r_{u,i}-R_{u,i})^{2},\ \ if\ (|r_{u,i}-R_{u,i}|)\ \leq\ \delta\\ \delta\times|r_{u,i}-R_{u,i}|-\frac{1}{2}\ *\ (\delta)^{2},\ \ Otherwise\end{cases}  \tag{7}\]  
where the true value of user \(u\) invoking movies \(I\) is \(r_{u,i}\), \(R_{u,i}\) is the predicted rating of user \(u\) invoking movies \(i\) and \(\delta\) is the threshold value, which is set to 1.0. Optimizer  
An optimizer is a function that changes a neural network's weight and learning rate. As a result, it contributes to decreasing overall loss while also improving precision. There are several optimizers [69; 70], i.e., Gradient Descent, Stochastic Gradient Descent, Adagrade, Adadelta, Adam, etc. Gradient Descent [69] updates weight and bias using the entire training data. It is the simplest basic optimizer, which reduces the loss and reaches the minima by simply using the derivative of the loss function and the learning rate. Stochastic Gradient Descent [69] is a modified version of the GD method, where the model parameters are updated on every iteration. Mini-batch [70] is a version of this GD technique in which model parameters are changed in small batches. As a result, the model uses less memory and has a low variance. Gradient Descent with Momentum [69] calculates an exponentially weighted average of the gradients and update weights using that gradient. The learning rate is constant in all of these optimizers. In the Adagrad optimizer [69], different learning rates are used for each parameter. It adapts the lower learning rate to the parameters associated with frequently occurring features and the larger learning rate for parameters associated with infrequent features. Adadelta [71] is an Adagrad addition that aims to slow down the program's aggressive, monotonically declining learning rate. Instead of accumulating all past squared gradients, Adadelta restricts the window of accumulated past gradients to some fixed size. The RMSprop [71] optimizer is a momentum-based version of the gradient descent technique. It limits oscillations in the vertical plane. As a result, we can boost our learning rate to a horizontal direction and converge faster.