# Sequential Movie Genre Prediction Using Average Transition Probability with Clustering
## 3 Genre Prediction Algorithm
### Model Training
#### 3.4.2 Training Models  
In our approach, we use RNN-based models to capture the long-term dynamics of sequential movie genre data such as RNN, LSTM, and GRU. These methods are described in detail as follows:  
**(1) RNN. ** First, RNN [30] is a deep learning model that was designed to be useful for sequential data processing. RNN is a recursive model that performs the same function on all input data, and the output for the current input depends on past calculations. When the output data are generated, they are copied and sent back into the recurrent network. Based on the current input and output generated from the previous input, the RNN learns certain sequential data and makes a decision. To formally describe the method, let \(x_{t}\) be the input vector and \(y_{t}\) be the output vector at time \(t\) as shown in Figure 7. Then, the state value of hidden layer \(h_{t}\) at time \(t\) is given by:  
\[h_{t}=\tanh(Ux_{t}+Wh_{t-1}+b), \tag{6}\]  
where \(U\) and \(W\) are model parameter matrices and \(b\) is a constant vector. As a function of \(h_{t}\), we consider a hyperbolic tangential function \(\tanh(\cdot)\). The output vector \(y_{t}\) is given by:  
\[y_{t}=f(Vh_{t}+b), \tag{7}\]  
where \(V\) is a model parameter and \(f\) is an activation function. The RNN is optimized to approximate the function by capturing sequential patterns. However, if the length of the sequence input to the RNN is long, the effect of the elements at the beginning of the sequence gradually decreases as the time step progresses and the effect disappears after a certain period of time. This is because the constant value is multiplied equally in each cycle. This is called a long-term dependency problem. RNN is useful for a short sequence of data. **(2) LSTM. ** To overcome the main disadvantage of RNN, LSTM [31] has been introduced as an improved method. LSTM is a kind of RNN capable of selectively remembering sequences for a long period of time. The main difference from RNN is that LSTM introduces a \"cell state\" for each time \(t\), which allows information to flow unaltered. In LSTM, the cell state is regarded as a long-term memory because the previous information is stored in it as a recursive nature of the cells. The forget gate is used to update the cell states. A forget gate outputs values for which information to forget by multiplying 0 to a position in the matrix. If the output of the forget gate is 1, the information is kept in the cell. The input gates determine which information should enter the cell states. Finally, the output gate determines which information should be passed on to the next hidden state. Based on this fact, LSTM addresses the long-term dependency problem of the RNN. In general, LSTM consists of the following four parts as shown in Figure 8:  
**(i)**: _Forget Gate Layer._ As a first part, the forget gate layer decides to filter some information from the cell state using a sigmoid function. It obtains information at \(h_{t-1}\) and \(x_{t}\) and outputs a number between 0 and 1 for each number in the cell state \(c_{t-1}\). The  
Figure 7: Recurrent neural network. number 1 implies \"completely keep this\" while 0 represents \"completely drop this\". The output of the forget gate vector \(t_{t}\) is given by: \[f_{t}=\sigma(W_{f}\cdot[h_{t-1},x_{t}]+b_{f}),\] (8) where \(\sigma\) is a sigmoid function and \(W_{f}\) and \(b_{f}\) are weight matrix and bias vector parameter. (ii) _Input Gate Layer._ In the next step, LSTM decides whether new information to store or not in the cell state. For this, an \"input gate layer\" decides the values to be updated as a sigmoid gate. Next, a tanh gate generates a vector of new values, \(\tilde{c}_{t}\), that could be added to the state. Then, these two layers are combined to create an update to the state. The input gate vector \(i_{t}\) is given by: \[i_{t}=\sigma(W_{i}\cdot[h_{t-1},x_{t}]+b_{i}),\] (9) where \(W_{i}\) and \(b_{i}\) are weight matrix and bias vector parameter.