The official source code for Linear-Layer-Enhanced Quantum Long Short-Term Memory for Carbon Price Forecasting, accepted at Quantum Machine Intelligence (July 2023).
This code implements the quantum LSTM for price forecasting problems. By changing the data, you can also execute it for other kinds of forecasting or regression problems.
@article{cao2023linear,
title={Linear-layer-enhanced quantum long short-term memory for carbon price forecasting},
author={Cao, Yuji and Zhou, Xiyuan and Fei, Xiang and Zhao, Huan and Liu, Wenxuan and Zhao, Junhua},
journal={Quantum Machine Intelligence},
volume={5},
number={2},
pages={26},
year={2023},
publisher={Springer}
}
python == 3.8
Use requirements.txt to install the dependencies for reproducing the code.
pip install -r requirement.txt
The experimental result is stored by WandB. You need to register your account first. See the quickstart of WandB here.
src/train.py
is the main entry for training different models.config.yaml
sets the configuration of data, model and training pipelines.data_utils.py
contains data modules of the dataset including data preprocessing etc.utils.py
includes utility functions.models/qlstm.py
andmodels/xx_qlstm.py
implement the quantum-classical models.
# train QLSTM
python src/train.py --batch_size 16 --model_name QLSTM --devices 16 --accelerator cpu --n_qubits 4
# train L-QLSTM
python src/train.py --batch_size 16 --model_name xx-QLSTM --devices 16 --accelerator cpu --n_qubits 4
# train LSTM
python src/run_lstm.py --seed 1 --data period2 --hidden_dim 3
This is the dataset of EU carbon market from 2014.01.01 to 2020.12.31.
Price
: carbon priceHigh
: highest priceLow
: lowest priceOpen
: opening priceVol
: trading volumeWeek
: week number of the yearYear
: year of the dayt
: remaining days to the last open day of the year
x_3d.csv
contains features of last day, day before last day, and weekday of last week.
x_5d.csv
contains features of last five days.
period1
contains data during 2014.01.01 - 2016.12.31.
period2
contains data from 2017.01.01 - 2020.12.31.
If you have any questions or need further clarification, please feel free to reach out to me at [email protected].