scRL.Trainer.trainer
- class scRL.Trainer.trainer(algo, gres, reward_type='c', reward_mode='Decision', starts_prob=True, X_latent=None, hidden_dim=128, num_episodes=10000, max_step=50, KNN=10, batch_size=64, capacity=10000, soft=True, target_update=50, gamma=0.9, tau=0.005, alpha=0.5, lr=0.001, actor_lr=0.0005, critic_lr=0.001)[source]
Reinforcement learning trainer class.
Parameter
- algo
Algorithm to train the agent. Three algorithms are included: ‘TabularQ’, ‘ActorCritic’, ‘DDQN’.
- gres
Grids results after all the preprocessings.
- reward_type
The reward type generated. (Default: ‘c’) Two types are included:’c’,’d’.
- reward_mode
The reward mode selected when generating the reward. (Default: ‘Decision’) Two modes are included:’Decision’,’Contribution’.
- simulating
Whether to train a simulator together. (Default: False)
- X_latent
Latent space for the input of deep environment. (Default: None)
- hidden_dim
The dimensionality of the hidden layer. (Default: 128)
- num_episodes
The maximum training episodes. (Default: 10000)
- max_step
Maximum steps the agent can travel in the environment. (Default: 50)
- KNN
Nearest neighbors for considering each grid points state value. (Default: 10)
- batch_size
The batch size during training (Default: 64)
- capacity
The size of replay buffer of DDQN. (Default: 10000)
- soft
Whether to soft update the target net of DDQN. (Default: True)
- target_update
Steps for udating target net of DDQN. (Default: 50)
- gamma
Decaying factor for reinforcement learning. (Default: .8)
- tau
Soft update percent for the target net of DDQN. (Default: .005)
- alpha
Learning rate for tabular Q learning. (Default: .5)
- lr
Learning rate for the DDQN. (Default: 1e-3)
- actor_lr
The actor learning rate for ActorCritic. (Default: 5e-4)
- critic_lr
The critic learning rate for ActorCritic. (Default: 1e-3)
- __init__(algo, gres, reward_type='c', reward_mode='Decision', starts_prob=True, X_latent=None, hidden_dim=128, num_episodes=10000, max_step=50, KNN=10, batch_size=64, capacity=10000, soft=True, target_update=50, gamma=0.9, tau=0.005, alpha=0.5, lr=0.001, actor_lr=0.0005, critic_lr=0.001)[source]
Methods
__init__(algo, gres[, reward_type, ...])eval_fate()train()train_simulator(num_episodes, latent_dim)