# A Microscopic Traffic Flow Data Generation Method Based on an Improved DCGAN
## 2 Materials and Methods
### Improved DCGAN Model
#### 2.1.2 Discriminator Model  
The parameters of vehicle trajectories not only have the characteristics of spatial distribution but also have a strong correlation with time, and the DCGAN network structure is not designed to process sequential data [23]. GRU is a variant of a recurrent neural network [24; 25]. Similarly to Long Short-Term Memory (LSTM), it is used to solve the problem in which the gradient of the RNN network disappears during training. GRU is simpler and more efficient than LSTM [26; 27; 28]. So, we added the GRU network to the discriminator to try to improve its ability to discriminate continuous data.  
The self-generated trajectory coordinate data of traffic participant vehicles in natural traffic flow are highly correlated with time; in particular, the \(x\)-coordinate of traffic participants has a certain increasing relationship in the time scale. Therefore, it is necessary that the generated data should also have a certain correlation in the time scale, and it is necessary to improve the discriminator of DCGAN to enable it to identify the feature changes among sequences. So, we introduced a gated neural network into the discriminator D network. The GRU has two gates: the update gate and the reset gate, which are used to determine the amount of past information used and the amount of past information forgotten.  
Its network structure is shown in Figure 3, and the formula for the update gate is shown below:  
\[z_{t}=\sigma\Big{(}W_{z}x_{t}+U_{z}h_{(t-1)}\Big{)} \tag{1}\]  
where \(\sigma\) represents the sigmoid activation function, \(W_{z}\) and \(U_{z}\) represent the weight matrix, \(x_{t}\) is the input vector, and \(h_{(t-1)}\) indicates the implied state of the previous moment. The calculation formula for the reset gate is:  
\[r_{t}=\sigma\Big{(}W_{r}x_{t}+U_{r}h_{(t-1)}\Big{)} \tag{2}\]  
Similar to the update gate, \(\sigma\) represents the sigmoid activation function, \(W_{z}\) and \(U_{z}\) represent the weight matrix, \(x_{t}\) is the input vector, and \(h_{(t-1)}\) indicates the implied state of  
Figure 3: Structure of GRU cell.  
the previous moment. Candidate memory content is related to past information retained by the reset gate, and its calculation formula is as follows:  
\[h_{t}^{\prime}=\tan\hbar(Wx_{t}+r_{t}\odot Ult_{t-1}) \tag{3}\]  
where \(h_{t}^{\prime}\) represents the new memory content, \(\odot\) represents the Hadamard product, and the input \(x_{t}\) and the previous time step's information \(h_{t-1}\) first undergo a linear transformation, i.e., left multiplication of the matrices \(W\) and \(U\), respectively.  
The retained memory content is controlled by the update gate and reset gate and its calculation formula is as follows:  
\[h_{t}=z_{t}\odot h_{t-1}+(1-z_{t})\odot h_{t}^{\prime} \tag{4}\]  
where \(z_{t}\) is the result of the activation of the update gate, which also controls the inflow of information in the form of gating; the Hadamard product of \(z_{t}\) and \(h_{t-1}\) represents the information retained in the previous time step related to the final memory, and this information, plus the information retained in the current memory related to the final memory is equal to the output of the final gated loop unit.  
The improved discriminator based on the GRU network has a similar basic structure, using GRU units after the convolutional layer to replace the original fully connected layer. The final discriminator structure is shown in Figure 4.  
Figure 4: Discriminator structure diagram.