PacktPublishing / Deep-Reinforcement-Learning-Hands-On-Second-Edition

Deep-Reinforcement-Learning-Hands-On-Second-Edition, published by Packt
MIT License
1.17k stars 545 forks source link

Problem in all code execution for CH.8 #30

Closed Psiopteryx closed 4 years ago

Psiopteryx commented 4 years ago

Hello, Loving the book, but in Ch. 8 receive this error for all scripts: Traceback (most recent call last): File "C:/Users/hj/PycharmProjects/DeepLearning/01_dqn_basic.py", line 62, in common.setup_ignite(engine, params, exp_source, NAME) File "C:\Users\hj\PycharmProjects\DeepLearning\lib\common.py", line 158, in setup_ignite handler.attach(engine) File "C:\Users\hj\Anaconda3\envs\torch13\lib\site-packages\ptan\ignite.py", line 35, in attach engine.register_events(*EpisodeEvents) File "C:\Users\hj\Anaconda3\envs\torch13\lib\site-packages\ignite\engine\engine.py", line 223, in register_events "Value at {} of event_names should be a str or EventEnum, but given {}".format(index, e) TypeError: Value at 0 of event_names should be a str or EventEnum, but given EpisodeEvents.EPISODE_COMPLETED

I'm running torch 1.3, and Ignite 0.4.2, and PTAN 0.6

vfdev-5 commented 4 years ago

Hi, this is due to newer version of ignite 0.4.2. Please, use the version from requirements or 0.3.0. They should be OK.

On Tue, Oct 13, 2020, 19:09 Psiopteryx notifications@github.com wrote:

Hello, Loving the book, but in Ch. 8 receive this error for all scripts: Traceback (most recent call last): File "C:/Users/hj/PycharmProjects/DeepLearning/01_dqn_basic.py", line 62, in common.setup_ignite(engine, params, exp_source, NAME) File "C:\Users\hj\PycharmProjects\DeepLearning\lib\common.py", line 158, in setup_ignite handler.attach(engine) File "C:\Users\hj\Anaconda3\envs\torch13\lib\site-packages\ptan\ignite.py", line 35, in attach engine.register_events(*EpisodeEvents) File "C:\Users\hj\Anaconda3\envs\torch13\lib\site-packages\ignite\engine\engine.py", line 223, in register_events "Value at {} of event_names should be a str or EventEnum, but given {}".format(index, e) TypeError: Value at 0 of event_names should be a str or EventEnum, but given EpisodeEvents.EPISODE_COMPLETED

I'm running torch 1.3, and Ignite 0.4.2, and PTAN 0.6

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PacktPublishing/Deep-Reinforcement-Learning-Hands-On-Second-Edition/issues/30, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASYOH6B5PK6SYA5VRREXBDSKSCUBANCNFSM4SPJBYPQ .

Psiopteryx commented 4 years ago

Thanks for getting back so quickly; it now executes but there's another small bug, NotADirectoryError: [WinError 267] The directory name is invalid: 'runs/2020-10-13T18:28-pong-01_baseline'

I'll work on that one unless you've come across it before!

On Tue, Oct 13, 2020 at 6:18 PM vfdev notifications@github.com wrote:

Hi, this is due to newer version of ignite 0.4.2. Please, use the version from requirements or 0.3.0. They should be OK.

On Tue, Oct 13, 2020, 19:09 Psiopteryx notifications@github.com wrote:

Hello, Loving the book, but in Ch. 8 receive this error for all scripts: Traceback (most recent call last): File "C:/Users/hj/PycharmProjects/DeepLearning/01_dqn_basic.py", line 62, in common.setup_ignite(engine, params, exp_source, NAME) File "C:\Users\hj\PycharmProjects\DeepLearning\lib\common.py", line 158, in setup_ignite handler.attach(engine) File "C:\Users\hj\Anaconda3\envs\torch13\lib\site-packages\ptan\ignite.py", line 35, in attach engine.register_events(*EpisodeEvents) File

"C:\Users\hj\Anaconda3\envs\torch13\lib\site-packages\ignite\engine\engine.py", line 223, in register_events "Value at {} of event_names should be a str or EventEnum, but given {}".format(index, e) TypeError: Value at 0 of event_names should be a str or EventEnum, but given EpisodeEvents.EPISODE_COMPLETED

I'm running torch 1.3, and Ignite 0.4.2, and PTAN 0.6

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub < https://github.com/PacktPublishing/Deep-Reinforcement-Learning-Hands-On-Second-Edition/issues/30 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AASYOH6B5PK6SYA5VRREXBDSKSCUBANCNFSM4SPJBYPQ

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PacktPublishing/Deep-Reinforcement-Learning-Hands-On-Second-Edition/issues/30#issuecomment-707890111, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABF65AZOBVDDI7N56UBWKWTSKSDU5ANCNFSM4SPJBYPQ .

Shmuma commented 4 years ago

Yep, that's due to windows names limitation - it doesn't like semicolon in the name (and I've tested the code only on linux machine)

You should tweak this line: https://github.com/PacktPublishing/Deep-Reinforcement-Learning-Hands-On-Second-Edition/blob/master/Chapter08/lib/common.py#L180

Shmuma commented 4 years ago

I guess changing it to the

now = datetime.now().isoformat(timespec='minutes').replace(':', '')

should be enough

Psiopteryx commented 4 years ago

Thank you, worked a treat.

Ignite's now complaining (perhaps this more Windows quirkiness): Traceback (most recent call last): File "C:/Users/hj/PycharmProjects/DeepLearning/03_dqn_double.py", line 101, in engine.run(common.batch_generator(buffer, params.replay_initial, params.batch_size)) File "C:\Users\hj\Anaconda3\envs\torch13\lib\site-packages\ignite\engine\engine.py", line 835, in run raise ValueError("Argument epoch_length should be defined if data is an iterator") ValueError: Argument epoch_length should be defined if data is an iterator

On Tue, Oct 13, 2020 at 6:37 PM Max Lapan notifications@github.com wrote:

I guess changing it to the

now = datetime.now().isoformat(timespec='minutes').replace(':', '')

should be enough

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PacktPublishing/Deep-Reinforcement-Learning-Hands-On-Second-Edition/issues/30#issuecomment-707900740, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABF65AZE3WEBGDJZCN2TB73SKSF4RANCNFSM4SPJBYPQ .

vfdev-5 commented 4 years ago

@Psiopteryx well, you have to use the version from the requirements: pytorch-ignite==0.2.1

vfdev-5 commented 4 years ago

@Shmuma any plans to update the code to the latest ignite version ?

Psiopteryx commented 4 years ago

Thank you again, works fine under 0.2.1. Had thought 0.3 was fine for Ignite.

On Tue, Oct 13, 2020 at 6:53 PM vfdev notifications@github.com wrote:

@Psiopteryx https://github.com/Psiopteryx well, you have to use the version from the requirements: pytorch-ignite==0.2.1

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PacktPublishing/Deep-Reinforcement-Learning-Hands-On-Second-Edition/issues/30#issuecomment-707909292, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABF65AZFLAR3SR4V5SBQAXDSKSHZTANCNFSM4SPJBYPQ .

Shmuma commented 4 years ago

@vfdev-5 yep, want to update all the samples to recent versions, but have been procastinating this for a while :)

AndreasGronlund commented 4 years ago

In ptan:

A) In the file https://github.com/Shmuma/ptan/blob/master/ptan/ignite.py

  1. Make the import from ignite.engine import EventEnum

  2. Change line 10: class EpisodeEvents(enum.Enum): -> class EpisodeEvents(EventEnum): line 106: class PeriodEvents(enum.Enum): -> class PeriodEvents(EventEnum):

B) Change requirements to the latest versions of torch and torch-ignite In the files https://github.com/Shmuma/ptan/blob/master/requirements.txt and https://github.com/Shmuma/ptan/blob/master/setup.py

C) python setup.py install

Shmuma commented 4 years ago

@AndreasGronlund Thanks! Finally started working on pytorch 1.7 support, could be tracked (and contributed) here: https://github.com/Shmuma/ptan/tree/torch-1.7 and here: https://github.com/PacktPublishing/Deep-Reinforcement-Learning-Hands-On-Second-Edition/tree/torch-1.7 :)

Shmuma commented 4 years ago

This issue was fixed in branches torch-1.7 in book repo and ptan. New ptan package haven't been released yet, so, you'll need to setup it from branch, but examples up to chapter 8 was tested on torch-1.7 and ignite-0.4.2