This library simplifies the process of training reinforcement learning agents using Keras and PyTorch. By inheriting from the provided classes, training agents becomes straightforward, allowing users to focus on developing cutting-edge AI without the typical complexities of algorithm implementation.
Note_rl is a powerful reinforcement learning library designed specifically for use with Keras and PyTorch, allowing users to effectively train agents with minimal effort. By simply inheriting from the RL or RL_pytorch classes, developers can streamline the training process for their models built within these frameworks.
Below are some code snippets illustrating how to utilize Note_rl for training agents in both Keras and PyTorch:
import tensorflow as tf
from Note_rl.policy import EpsGreedyQPolicy
from Note_rl.examples.keras.DQN import DQN
model = DQN(4, 128, 2)
model.set(policy=EpsGreedyQPolicy(0.01), pool_size=10000, batch=64, update_steps=10)
optimizer = tf.keras.optimizers.Adam()
train_loss = tf.keras.metrics.Mean(name='train_loss')
model.train(train_loss, optimizer, 100)
import tensorflow as tf
from Note_rl.policy import SoftmaxPolicy
from Note_rl.examples.keras.PPO import PPO
model = PPO(4, 128, 2, 0.7, 0.7)
model.set(policy=SoftmaxPolicy(), pool_size=10000, batch=64, update_steps=1000, PPO=True)
optimizer = [tf.keras.optimizers.Adam(1e-4), tf.keras.optimizers.Adam(5e-3)]
train_loss = tf.keras.metrics.Mean(name='train_loss')
model.train(train_loss, optimizer, 100)
import torch
from Note_rl.policy import EpsGreedyQPolicy
from Note_rl.examples.pytorch.DQN import DQN
model = DQN(4, 128, 2)
model.set(policy=EpsGreedyQPolicy(0.01), pool_size=10000, batch=64, update_steps=10)
optimizer = torch.optim.Adam(model.param)
model.train(optimizer, 100)
import torch
from Note_rl.policy import SoftmaxPolicy
from Note_rl.examples.pytorch.MADDPG import DDPG
model = DDPG(128, 0.1, 0.98, 0.005)
model.set(policy=SoftmaxPolicy(), pool_size=3000, batch=32, trial_count=10, MARL=True)
optimizer = [torch.optim.Adam(model.param[0]), torch.optim.Adam(model.param[1])]
model.train(optimizer, 100)
The library supports distributed training techniques like MirroredStrategy and MultiWorkerMirroredStrategy, enabling efficient scaling of the training process across multiple GPUs or machines.
import tensorflow as tf
from Note_rl.policy import EpsGreedyQPolicy
from Note_rl.examples.keras.DQN import DQN
strategy = tf.distribute.MirroredStrategy()
BATCH_SIZE_PER_REPLICA = 64
GLOBAL_BATCH_SIZE = BATCH_SIZE_PER_REPLICA * strategy.num_replicas_in_sync
with strategy.scope():
model = DQN(4, 128, 2)
optimizer = tf.keras.optimizers.Adam()
model.set(policy=EpsGreedyQPolicy(0.01), pool_size=10000, batch=GLOBAL_BATCH_SIZE, update_steps=10)
model.distributed_training(optimizer, strategy, 100)
Note_rl enables users to dive into reinforcement learning with ease, offering comprehensive examples and a clear, structured approach. For further details and additional examples, explore the documentation.
No comments yet.
Sign in to be the first to comment.