The Deep Q learner class.
More...
|
| None | __init__ (self, str env_path, str urdf_path=None, str urdf=None, bool use_graphics=False, str network_path="") |
| | The DeepQLearner class initializer. More...
|
| |
|
def | handler (self, *_) |
| | Handler for saving the Deep Q-network upon interrupting the execution of the program.
|
| |
| None | save (self, str path="./src/rl/networks/most_recently_saved_network.pkl") |
| | Save the trained network in a pickle file. More...
|
| |
| np.ndarray | get_action_space (self, number_of_joints) |
| | Get all possible actions given the amount of joints. More...
|
| |
| Tuple[int, np.ndarray, Tuple] | get_random_wall (self) |
| | Get one of the possible walls at random. More...
|
| |
| DQN | make_dqn (self, network_path="") |
| | Create an instance of the DQN. More...
|
| |
| Tuple[int, np.ndarray] | step (self, np.ndarray state) |
| | Move 1 step forward in the simulation. More...
|
| |
| float | learn (self, int number_of_episodes=10000, int steps_per_episode=1000, bool logging=False) |
| | The training or testing loop (depending on variable 'training') of the deep q-learning. More...
|
| |
| int | predict (self, np.ndarray state) |
| | Pick the best or a random action depending on epsilon value of the Deep-Q Network. More...
|
| |
|
|
| goal_ball_diameter |
| |
|
| use_walls |
| |
|
| env |
| |
|
| x_range |
| |
|
| y_range |
| |
|
| z_range |
| |
|
| actions |
| |
|
| dqn |
| |
|
| training |
| |
|
| logger |
| |
|
| walls |
| |
|
| wall_centers |
| |
|
| current_wall_index |
| |
|
|
int | STATE_SIZE = 6 |
| |
|
int | WALL_STATE_SIZE = 9 |
| |
The Deep Q learner class.
Defines the class that will learn based on a Deep-Q Network.
◆ __init__()
| None rl.deep_q_learning.DeepQLearner.__init__ |
( |
|
self, |
|
|
str |
env_path, |
|
|
str |
urdf_path = None, |
|
|
str |
urdf = None, |
|
|
bool |
use_graphics = False, |
|
|
str |
network_path = "" |
|
) |
| |
The DeepQLearner class initializer.
- Parameters
-
| env_path | Path of the environment executable. |
| urdf_path | Path to the robot urdf file. |
| urdf | Instance that represents the robot urdf. |
| use_graphics | Boolean that turns graphics on or off. |
| network_path | Path to the Deep-Q network that should be used. |
- Returns
- An instance of the DeepQLearner class.
◆ get_action_space()
| np.ndarray rl.deep_q_learning.DeepQLearner.get_action_space |
( |
|
self, |
|
|
|
number_of_joints |
|
) |
| |
Get all possible actions given the amount of joints.
- Parameters
-
| number_of_joints | The amount of joints the robot arm has. A complex module has 2 joints, rotating and tilting. |
- Returns
- A list of the actions
◆ get_random_wall()
| Tuple[int, np.ndarray, Tuple] rl.deep_q_learning.DeepQLearner.get_random_wall |
( |
|
self | ) |
|
Get one of the possible walls at random.
- Returns
- A wall.
◆ learn()
| float rl.deep_q_learning.DeepQLearner.learn |
( |
|
self, |
|
|
int |
number_of_episodes = 10000, |
|
|
int |
steps_per_episode = 1000, |
|
|
bool |
logging = False |
|
) |
| |
The training or testing loop (depending on variable 'training') of the deep q-learning.
- Parameters
-
| number_of_episodes | Maximum amount of episodes. |
| steps_per_episode | Maximum amount of steps each episode. |
| logging | If true there will be wandb logs |
- Returns
- Success rate throughout training.
◆ make_dqn()
| DQN rl.deep_q_learning.DeepQLearner.make_dqn |
( |
|
self, |
|
|
|
network_path = "" |
|
) |
| |
Create an instance of the DQN.
- Parameters
-
| network_path | Path to network, if the goal is testing, not training. |
- Returns
- A DQN instance.
◆ predict()
| int rl.deep_q_learning.DeepQLearner.predict |
( |
|
self, |
|
|
np.ndarray |
state |
|
) |
| |
Pick the best or a random action depending on epsilon value of the Deep-Q Network.
- Parameters
-
| state | Current state of the environment. |
- Returns
- The chosen action.
◆ save()
| None rl.deep_q_learning.DeepQLearner.save |
( |
|
self, |
|
|
str |
path = "./src/rl/networks/most_recently_saved_network.pkl" |
|
) |
| |
Save the trained network in a pickle file.
- Parameters
-
| path | Path to file where the network will be saved. |
◆ step()
| Tuple[int, np.ndarray] rl.deep_q_learning.DeepQLearner.step |
( |
|
self, |
|
|
np.ndarray |
state |
|
) |
| |
Move 1 step forward in the simulation.
- Parameters
-
| state | Current state of the environment. |
- Returns
- The action that was taken and the observations that were made.
The documentation for this class was generated from the following file: