Comments (5)
which versions of numpy and pytorch are you using? This is certainly an issue with package versions.
from deep-q-learning-paper-to-code.
My numpy version is 1.18.1
My torch version is 1.4.0
from deep-q-learning-paper-to-code.
OK, I can't replicate the error but it looks like there are two possibilities.
- indices are not the correct dtype
- actions are not the correct dtype
Please verify the dtype of indices and actions by printing indices.dtype and actions.dtype to the terminal.
Make sure they are both np.int64.
If one (or both) are not, then change the declaration of indices to include dtype=np.int64 in line 87
and also change the declaration of action_memory in replay_memory.py to be dtype=np.int64
Also, for good measure (because it generates a warning with this combination of packages), change the dtype of terminal_memory to be np.bool (also in the replay_memory.py file).
Let me know if that helps!
from deep-q-learning-paper-to-code.
The datatype of "indices" was int32
I changed
indices = np.arange(self.batch_size)
into
indices = np.arange(self.batch_size, dtype=np.int64)
The datatype of actions was torch.int32
I changed
actions = T.tensor(action).to(self.q_eval.device)
into
actions = T.tensor(action, dtype=T.long).to(self.q_eval.device)
After these changes I got a new error " indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead."
This problem seems to be solved by changing:
self.terminal_memory = np.zeros(self.mem_size, dtype=np.uint8)
into
self.terminal_memory = np.zeros(self.mem_size, dtype=np.bool)
Now the agent is training to play Pong :)
Thanks very much for your help, I appreciate it a lot!
from deep-q-learning-paper-to-code.
Perfect. I have to set up a requirements file for this, as these errors didn't happen on earlier versions of PyTorch.
from deep-q-learning-paper-to-code.
Related Issues (14)
- Runtime error in cartpole_naive_dqn.py HOT 1
- Indention of DQN/preprocess_pseudocode is broken
- ndarray error
- No registered env with id: PongNoFrameskip-v4 HOT 2
- Network is not learning when convolutional layers are applied. HOT 2
- what if i set load_check point to true from argparser
- No gradient required for q_target calculation
- DQN implementation error
- The dqn_agent.py loss function is the wrong way around HOT 1
- Warning: indexing with dtype torch.uint8 is now deprecated, please use a dtype torch.bool instead.
- Viewing results of gameplay? HOT 3
- Regarding target calculations in DuelDDQN and indices
- Detach target nexwork in DQN
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deep-q-learning-paper-to-code.