reinforcement-learning

AttributeError: 'Sequential' object has no attribute 'model'

AttributeError: 'Sequential' object has no attribute 'model' Question: from tensorflow.keras.layers import Dense, Activation from tensorflow.keras.models import Sequential, load_model from tensorflow.keras.optimizers import Adam def build_dqn(lr, n_actions, input_dims, fc1_dims, fc2_dims): model = Sequential([ Dense(fc1_dims, input_shape=(input_dims,)), Activation(‘relu’), Dense(fc2_dims), Activation(‘relu’), Dense(n_actions)]) model.compile(optimizer=Adam(lr=lr), loss=’mse’) return model I am trying to understand Double Deep Q-Learning. There is a pretty good lecture …

Total answers: 1

Keras symbolic inputs/outputs do not implement `__len__` error

Keras symbolic inputs/outputs do not implement `__len__` error Question: I want to make an AI playing my custom environment, unfortunately, when I run my code, following error accrues: File "C:Program FilesJetBrainsPyCharm Community Edition 2021.2pluginspython-cehelperspydev_pydev_bundlepydev_umd.py", line 198, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script File "C:Program FilesJetBrainsPyCharm Community Edition 2021.2pluginspython-cehelperspydev_pydev_imps_pydev_execfile.py", line 18, in execfile …

Total answers: 2

Keras: AttributeError: 'Adam' object has no attribute '_name'

Keras: AttributeError: 'Adam' object has no attribute '_name' Question: I want to compile my DQN Agent but I get error: AttributeError: ‘Adam’ object has no attribute ‘_name’, DQN = buildAgent(model, actions) DQN.compile(Adam(lr=1e-3), metrics=[‘mae’]) I tried adding fake _name but it doesn’t work, I’m following a tutorial and it works on tutor’s machine, it’s probably some …

Total answers: 3

How to use a rule-based 'expert' for imitation learning?

How to use a rule-based 'expert' for imitation learning? Question: I am currently training a PPO model for a simulation. The PPO model fails to understand that certain conditions will lead to no reward. These conditions that lead to no reward are very simple rules. I was trying to use these rules to create an …

Total answers: 2

Stable-Baselines3 log rewards

Stable-Baselines3 log rewards Question: How can I add the rewards to tensorboard logging in Stable Baselines3 using a custom environment? I have this learning code model = PPO( "MlpPolicy", env, learning_rate=1e-4, policy_kwargs=policy_kwargs, verbose=1, tensorboard_log="./tensorboard/") Asked By: Mario || Source Answers: As by their documentation you can log arbitrary values by creating your own callback: import …

Total answers: 3

using DQN to solve shortest path

using DQN to solve shortest path Question: I’m trying to find out if DQN can solve the shortest path algorithm so I have this Dataframe which contains a source which has nodes id ,end which represents the destination and also has nodes id, and the weights which represent the distance of the edge and then …

Total answers: 1

what does "IndexError: index 20 is out of bounds for axis 1 with size 20"

what does "IndexError: index 20 is out of bounds for axis 1 with size 20" Question: I was working on q learning in a maze environment, However, at the initial stage, it was working fine but afterward, I was getting the following max_future_q = np.max(q_table[new_discrete_state]) IndexError: index 20 is out of bounds for axis 1 …

Total answers: 3

Gym's box 2d (openAI) doesn't install successfully (pip error)

Gym's box 2d (openAI) doesn't install successfully (pip error) Question: I’m trying to do the follow code with OpenAI: import gym env = gym.make(‘CarRacing-v0′) env.reset() for _ in range(1000): env.render() env.step(env.action_space.sample()) but it throws the error: fn = getattr(mod, attr_name) AttributeError: module ‘gym.envs.box2d’ has no attribute ‘CarRacing’ And then I try to install box2d by …

Total answers: 4

Pytorch – going back and forth between eval() and train() modes

Pytorch – going back and forth between eval() and train() modes Question: I’m studying “Deep Reinforcement Learning” and build my own example after pytorch’s REINFORCEMENT LEARNING (DQN) TUTORIAL. I’m implement actor’s strategy as follows: 1. model.eval() 2. get best action from a model 3. self.net.train() The question is: Does going back and forth between eval() …

Total answers: 2

How can I change this to use a q table for reinforcement learning

How can I change this to use a q table for reinforcement learning Question: I am working on learning q-tables and ran through a simple version which only used a 1-dimensional array to move forward and backward. now I am trying 4 direction movement and got stuck on controlling the person. I got the random …

Total answers: 1