stefan-jansen / machine-learning-for-trading

Code for Machine Learning for Algorithmic Trading, 2nd edition.
https://ml4trading.io
12.57k stars 4.03k forks source link

`ddqn.experience`'s `action` data type problem in `22_deep_reinforcement_learning`/`04_q_learning_for_trading.ipynb` #271

Closed DavidHJong closed 1 year ago

DavidHJong commented 1 year ago

Describe the bug

To Reproduce

  1. Run the training for like 300 episodes.
  2. Execute the below code, which will show a list of nth ddqn.experience whose action is not an integer.
    all_action_list = [ddqn.experience[i][1] for i in range(len(ddqn.experience))]
    for i in range(len(all_action_list)):
    if type(all_action_list[i]) != int:
        print(i)

Question

stefan-jansen commented 1 year ago

Based on your other issue, differences may be due to using more recent open AI gym versions, which generates what the current state (this_state = first entry in transition to memorize).

for episode in range(1, max_episodes + 1):
    this_state = trading_environment.reset()
    for episode_step in range(max_episode_steps):

Hope this helps.