SAC¶
Example¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | from rlzoo.common.env_wrappers import build_env
from rlzoo.common.utils import call_default_params
from rlzoo.algorithms import SAC
AlgName = 'SAC'
EnvName = 'Pendulum-v0' # only continuous action
EnvType = 'classic_control'
# EnvName = 'BipedalWalker-v2'
# EnvType = 'box2d'
# EnvName = 'Ant-v2'
# EnvType = 'mujoco'
# EnvName = 'FetchPush-v1'
# EnvType = 'robotics'
# EnvName = 'FishSwim-v0'
# EnvType = 'dm_control'
# EnvName = 'ReachTarget'
# EnvType = 'rlbench'
env = build_env(EnvName, EnvType)
alg_params, learn_params = call_default_params(env, EnvType, AlgName)
alg = eval(AlgName+'(**alg_params)')
alg.learn(env=env, mode='train', render=False, **learn_params)
alg.learn(env=env, mode='test', render=True, **learn_params)
|
Soft Actor-Critic¶
-
class
rlzoo.algorithms.sac.sac.
SAC
(net_list, optimizers_list, replay_buffer_capacity=500000.0)[source]¶ Soft Actor-Critic
-
learn
(env, train_episodes=1000, test_episodes=1000, max_steps=150, batch_size=64, explore_steps=500, update_itr=3, policy_target_update_interval=3, reward_scale=1.0, save_interval=20, mode='train', AUTO_ENTROPY=True, render=False, plot_func=None)[source]¶ Parameters: - env – learning environment
- train_episodes – total number of episodes for training
- test_episodes – total number of episodes for testing
- max_steps – maximum number of steps for one episode
- batch_size – udpate batchsize
- explore_steps – for random action sampling in the beginning of training
- update_itr – repeated updates for single step
- policy_target_update_interval – delayed update for the policy network and target networks
- reward_scale – value range of reward
- save_interval – timesteps for saving the weights and plotting the results
- mode – ‘train’ or ‘test’
- AUTO_ENTROPY – automatically updating variable alpha for entropy
- render – if true, visualize the environment
- plot_func – additional function for interactive module
-