Coder Social home page Coder Social logo

Comments (5)

philtabor avatar philtabor commented on August 11, 2024

which versions of numpy and pytorch are you using? This is certainly an issue with package versions.

from deep-q-learning-paper-to-code.

Ningizza avatar Ningizza commented on August 11, 2024

My numpy version is 1.18.1
My torch version is 1.4.0

from deep-q-learning-paper-to-code.

philtabor avatar philtabor commented on August 11, 2024

OK, I can't replicate the error but it looks like there are two possibilities.

  1. indices are not the correct dtype
  2. 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.

Ningizza avatar Ningizza commented on August 11, 2024

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.

philtabor avatar philtabor commented on August 11, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.