prevision_quantum_nn.applications.reinforcement_learning.q_learning

Q-Learning module

Module Contents

Classes

QLearner

Q-table Learner

class prevision_quantum_nn.applications.reinforcement_learning.q_learning.QLearner(params)

Bases: prevision_quantum_nn.applications.reinforcement_learning.base_learner.BaseLearner

Q-table Learner

This class implements a Q-table.

params

containing the parameters of the model

Type

dictionary

get_cell(self, state)

Returns the cell in which the state is.

Parameters

state (numpy array) – state at which we wish to obtain the corresponding cell

Returns

tuple

cell indices at which the Q-table will be updated

Return type

cell

fit(self, state, reward)

Fits the Q-table at a given state.

Parameters
  • state (numpy array) – state at which the Q-table needs to fit

  • reward (float) – reward that was yielded when passing through this state

forward(self, state, action=None)

Forwards the Q-able through the state (action) provided.

Parameters
  • state (numpy array) – state at which the Q-table needs to be evaluated

  • action (int) – if the Q-table is formed with the state action method, action needs to be provided as an option.

Returns

float

the actual Q-value at the state provided

Return type

value