Help for understanding RNN sequence inputs and output data

I need to develop a system where the output data is dependent on the previous input. The system expected to have one input and one output at a time.

For training, I collect the sequences, say for example x1, x2, x3, …, xn, when I feed them as batches to an rnn/gru, the out put is in the size of (N, L, Hout), using batch first option. But I only need the data at the size (N, L). I’m not sure how to use a linear layer to combine them to get the output in the desired size, because when using the system (after training/testing) I need to feed only one data point and need to obtain one data point for that input.

Can you be more specific about task you want to learn. I can’t tell for sure if it’s a basic classification task or more akin to a sequence labeling task.

Thank you for the reply. I have one-dimensional sensor data as a time series, such as ([x_1, x_2, x_3, ..., x_n]$. The input to the RNN is of dimension ((N, L, 1)), and the output is of dimension (N, L, H_{out}), where N is the batch size, L is the sequence length, and H_{out} is the hidden size. I understand that the sequence of L data inputs produces L sequences of data at the output. The length of the sequence doesn’t matter as long as the hidden data is fed back to the RNN, so I can feed one input at an instant as soon as the data arrives from the sensor and get one data point for the corresponding input after it is processed by the RNN.

However, my original issue was how to reduce the dimension of the output data from (N, L, H_{out}) to (N, L, 1) as required. Now I realize that I can use an nn.Linear(H_{out}, 1) to do that job. I originally misunderstood that the matrix multiplication inside nn.Linear might multiply the inter-sequence data.