SELAB3 Python Code
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
rl.dqn.DQN Class Reference

The DQN class. More...

Public Member Functions

def __init__ (self, int number_of_actions, int state_size, network_path="")
 The RobotNetwork class initializer. More...
 
def save (self, str path)
 Save the network to a given path. More...
 
def update (self, np.ndarray state, np.ndarray next_state, int action, float reward, bool finished)
 Update the network, should happen between each state transition during training. More...
 
int get_best_action (self, np.ndarray state)
 Look up the best action for a given state. More...
 

Public Attributes

 eps
 
 gamma
 
 eps_end
 
 eps_decay
 
 batch_size
 
 mem_size
 
 hidden_nodes
 
 network
 
 optimizer
 
 memory
 

Detailed Description

The DQN class.

Defines the class that will represent the Deep Q-Network.

Constructor & Destructor Documentation

◆ __init__()

def rl.dqn.DQN.__init__ (   self,
int  number_of_actions,
int  state_size,
  network_path = "" 
)

The RobotNetwork class initializer.

Parameters
number_of_actionsThe number of hidden nodes for the hidden layers.
state_sizeThe number of variables in a state, important for the nodes needed as input.
network_pathThe path to the file that contains a (trained) network.
Returns
An instance of the DQN class.

Member Function Documentation

◆ get_best_action()

int rl.dqn.DQN.get_best_action (   self,
np.ndarray  state 
)

Look up the best action for a given state.

Parameters
stateAn input state representing the environment.
Returns
An action, represented as a number.

◆ save()

def rl.dqn.DQN.save (   self,
str  path 
)

Save the network to a given path.

Parameters
pathThe file path to save the network to.

◆ update()

def rl.dqn.DQN.update (   self,
np.ndarray  state,
np.ndarray  next_state,
int  action,
float  reward,
bool  finished 
)

Update the network, should happen between each state transition during training.

Parameters
stateThe start state of the environment.
next_stateThe resulting, next state after executing an action.
actionThe action that was executed.
rewardThe reward resulting from the action.
finishedIf the next_state is a finishing state.

The documentation for this class was generated from the following file: