0

I did this to study DQN. I am sure I have installed keras, because when I type into the command prompt pip install keras all I get is Requirement is Already Satisfied.

My code:

from dqn_agent import DQNAgent
from tetris import Tetris
from datetime import datetime
from statistics import mean, median
import random
from logs import CustomTensorBoard
from tqdm import tqdm

Getting error:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-1d98c5613f54> in <module>
----> 1 from dqn_agent import DQNAgent
      2 from tetris import Tetris
      3 from datetime import datetime
      4 from statistics import mean, median
      5 import random

ModuleNotFoundError: No module named 'dqn_agent'
milanbalazs
  • 4,811
  • 4
  • 23
  • 45
NoobCoder
  • 1
  • 4
  • Are you using the same python interpreter to run the code as the Executable that you used to install the package? Try using the same `python` command to install the package like `python3 -m pip install ` – hedy Aug 18 '20 at 05:44
  • now it says No module named 'keras' (sobs) – NoobCoder Aug 18 '20 at 05:50

1 Answers1

1

It looks like you may be trying to use keras-rl, not keras? If so, you will have to type pip install keras-rl in your terminal.

To import DQNAgent, you should modify from dqn_agent import DQNAgent to from rl.agents.dqn import DQNAgent.

For more information, check out the keras-rl github.

Akanksha Atrey
  • 780
  • 4
  • 8
  • I tried to fix this error, and another error came up:from tensorflow import keras from dqn_agent import DQNAgent from tetris import Tetris from datetime import datetime from statistics import mean, median import random from logs import CustomTensorBoard from tqdm import tqdm – NoobCoder Aug 19 '20 at 01:42
  • in 5 from statistics import mean, median 6 import random ----> 7 from logs import CustomTensorBoard 8 from tqdm import tqdm ~\DQNTETRIS\tetrisByQLearning-master\logs.py in 6 7 from keras.callbacks import TensorBoard ----> 8 from tensorflow.summary import FileWriter 9 10 class CustomTensorBoard(TensorBoard): ImportError: cannot import name 'FileWriter' from 'tensorflow.summary' (C:\Users\MSI\AppData\Roaming\Python\Python37\site-packages\tensorboard\summary\_tf\summary\__init__.py) – NoobCoder Aug 19 '20 at 01:43
  • I don't know what to do :( – NoobCoder Aug 19 '20 at 01:44
  • It looks like the above solved your DQNAgent error. This is a new error that popped up on line `from logs import CustomTensorBoard`. What version of tensorflow are you using? – Akanksha Atrey Aug 19 '20 at 19:42
  • It's a 2.3.0 version. – NoobCoder Aug 22 '20 at 01:54