control.reinforcement_learning.DQN package
Submodules
control.reinforcement_learning.DQN.Agent module
- class control.reinforcement_learning.DQN.Agent.Agent(env)
Bases:
objectDQN Agent - Take an environment - Set up the deep neural network - Store the experience - Choose action - Train the network - Evaluate the network
- evaluate_model(episodes, swingUp=False, render=True, plot=True, verbose=False, final=False)
Evaluate the model for a number of episodes
- parse_ini(ini_file)
Parse the ini file with the env parameters
- plot_value_policy(visual='2D', resolution=10, final=False)
Plot the value function and the policy of single pendulum
- policy(observation, type='epsilon_greedy')
Choose an action based on the policy
- save_metrics(episode, episode_reward, last_loss, last_epsilon, episode_time)
Save the metrics in a dataframe and export it to a csv file
- train()
Train the network
- train_model(render=True, plot=True, verbose=False, soft_start=False)
Train the model for a number of episodes and plot the reward
control.reinforcement_learning.DQN.DeepQNetwork module
- class control.reinforcement_learning.DQN.DeepQNetwork.DeepQNetwork(lr, num_actions, input_dims, fc_dims=[32, 32], opt='adam', loss='mse')
Bases:
objectDeep Q Network to approximate the Q function
- evaluate(states, q_targets, verbose=0)
Evaluate the network on a batch of states and q_targets
- predict(state)
Predict the Q values for a given state
- train_batch_gradientTape(states, q_targets)
Train the network on a batch of states and q_targets using GradientTape
- train_on_batch(states, q_targets)
Train the network on a batch of states and q_targets
control.reinforcement_learning.DQN.ReplayBuffer module
- class control.reinforcement_learning.DQN.ReplayBuffer.ReplayBuffer(size)
Bases:
objectStores and retrieves gameplay experiences
- sample_batch(batch_size)
Sample a random batch of experiences from the replay buffer
- store_tuple(state, action, reward, new_state, done)
Store the experience in the replay buffer