A PyTorch implementation of a single-layer Long Short-Term Memory (LSTM) model that predicts the next Transport Block (TB) usage in a given New Radio Vehicle-to-Everything (NR V2X) resource pool is named 'Walter - LSTM (WLSTM)'.
WLSTM is applicable for Semi-Persistent Scheduling (SPS) based on the multiple steps of regular historical data.
-
The slot number in a selection window for Vulnerable Road User (VRU):
$\tau$ . -
The independent subchannels number in the resource pool:
$N$ . -
The number of historical data:
$t$ . -
X-coordinates of the TB usage in the
$t$ -th selection window corresponding to the subchannel number:$x_t\in[1,2,\cdots,N]$ . -
Y-coordinates of the TB usage in the
$t$ -th selection window corresponding to the slot number:$y_t\in[1,2,\cdots,\tau]$ . -
The position of the TB usage in the
$t$ -th selection window:$[x_{t}, y_{t}]$ .
This project trains an LSTM-based model to predict
The model treats the task as a
- Input: Sequences length of
$t$ steps, and each step containing two-dimensional data:$[x_{1}, y_{1}],[x_{2}, y_{2}],\cdots,[x_{t}, y_{t}]$ . - Output:
$C_{t+1}$ for the$(t+1)$ -th selection window:$C_{t+1}=(x_{t+1}-1)\times \tau+y_{t+1}-1$ , where$C_{t+1}\in[0,1,2,\cdots,(N\times\tau-1)]$ . - Format: The input dataset is a CSV file, where odd rows contain X-coordinates (
$x_1, x_2,\cdots,x_t$ values corresponding to the subchannel number) and even rows contain Y-coordinates ($y_1,y_2,\cdots,y_t$ values corresponding to the slot number).
Example data structure:
| Row Numbuer | Values |
|---|---|
| 1 (X1) | 1, 1, 3, ... |
| 2 (Y1) | 11, 11, 16, ... |
git clone https://github.com/yyymk/WLSTM.git
pip install -r requirements.txt
torch numpy pandas scikit-learn matplotlib
-
Prepare your dataset in CSV format similar to RP_power_data.csv (included in the repo).
-
Run the training script: python3 WLSTM_train.py
-
After training, the script will output
$C_{t+1}$ for the$(t+1)$ -th selection window. The position$[x_{t+1}, y_{t+1}]$ in the$(t+1)$ -th selection window can be calculated by:$C_{t+1}=(y_{t+1}-1)\times N+x_{t+1}-1$ ,$x_{t+1}\in[1,2,\cdots,N]$ , and$y_{t+1}\in[1,2,\cdots,\tau]$ . -
By comparing the actual position with the predicted one, the accuracy can be obtained.
| Argument | Default | Description |
|---|---|---|
--data |
None | Path to your dataset CSV file |
--epochs |
50 | Number of training epochs |
--batch_size |
32 | Batch size |
--hidden_size |
128 | Number of hidden units in LSTM |
The model is a single-layer LSTM followed by a fully connected layer for classification:
- Input:
$t$ two-dimensional historical data$[x_{1}, y_{1}],[x_{2}, y_{2}],\cdots,[x_{t}, y_{t}]$ . - LSTM Layer: Hidden size of
$128$ , number of layers is$1$ . - Fully Connected Layer: Projects LSTM output to
$(N\times\tau)$ classes. - Output:
$(N\times\tau)$ classes for the$(t+1)$ -th selection window. - Loss: CrossEntropyLoss for multi-class classification.
-
Dataset Size: The model was trained on 5940 sequences of trajectory data.
-
Data Split: The dataset was split into training and testing sets with a ratio of 80% training and 20% testing.
-
Training Parameters:
Epochs:
$50$ ;Batch Size:
$32$ ;Hidden Size:
$128$ (number of units in the LSTM layer);Optimizer: Adam optimizer with a learning rate of
$0.001$ .Loss Function: CrossEntropyLoss for multi-class classification.
-
In our demo with default parameter settings (
$\tau=50, N=4$ , and$t=50$ ), the model achieved an accuracy of 23.57% on the test set after training.
This project is licensed under the MIT License.