File size: 2,594 Bytes
33cf5a4 4c4caa0 33cf5a4 610d962 d8e1dbc 951328d 33cf5a4 c1614dd 516c218 33cf5a4 fb93a74 33cf5a4 1dcf37d dd6a9d7 33cf5a4 dd6a9d7 33cf5a4 c1614dd 33cf5a4 7c10bc3 33cf5a4 dd6a9d7 33cf5a4 bfc0589 33cf5a4 | 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | ---
tags:
- myenv-v1
- ppo
- deep-reinforcement-learning
- reinforcement-learning
- custom-implementation
- deep-rl-course
model-index:
- name: PPO
results:
- task:
type: reinforcement-learning
name: reinforcement-learning
dataset:
name: myenv-v1
type: myenv-v1
metrics:
- type: mean_reward
value: -1.10 +/- 0.00
name: mean_reward
verified: false
---
# PPO Agent Playing myenv-v1
This is a trained model of a PPO agent playing callosp.
# Gameplay
<video controls src="https://huggingface.co/MRNH/ppo-callofsp/resolve/main/replay.mp4"></video>
# Hyperparameters
```python
{'exp_name': 'ppo_no_pbt'
'seed': 1
'torch_deterministic': True
'cuda': True
'track': False
'wandb_project_name': 'cleanRL'
'wandb_entity': None
'capture_video': False
'env_id': 'myenv-v1'
'total_timesteps': 10000
'learning_rate': 0.00025
'num_envs': 1
'num_steps': 2048
'anneal_lr': True
'anneal_ent_coef': False
'anneal_clip_coef': False
'gae': True
'gamma': 0.99
'gae_lambda': 0.95
'num_minibatches': 64
'update_epochs': 3
'norm_adv': True
'clip_coef': 0.2
'clip_vloss': True
'ent_coef': 0.03
'vf_coef': 0.5
'max_grad_norm': 0.5
'target_kl': None
'repo_id': 'MRNH/ppo-callofsp'
'save_path': 'agent.pt'
'save_every': 10
'batch_size': 2048
'minibatch_size': 32}
```
Structure Actor-critic:
```
def layer_init(layer, std=np.sqrt(2), bias_const=0.0):
torch.nn.init.orthogonal_(layer.weight, std)
torch.nn.init.constant_(layer.bias, bias_const)
return layer
class Agent(nn.Module):
def __init__(self, envs):
super().__init__()
obs_dim = int(np.array(envs.single_observation_space.shape).prod())
n_actions = envs.single_action_space.n
self.critic = nn.Sequential(
layer_init(nn.Linear(obs_dim, 64)),
nn.Tanh(),
layer_init(nn.Linear(64, 64)),
nn.Tanh(),
layer_init(nn.Linear(64, 1), std=1.0),
)
self.actor = nn.Sequential(
layer_init(nn.Linear(obs_dim, 64)),
nn.Tanh(),
layer_init(nn.Linear(64, 64)),
nn.Tanh(),
layer_init(nn.Linear(64, n_actions), std=0.01),
)
def get_value(self, x):
return self.critic(x)
def get_action_and_value(self, x, action=None):
logits = self.actor(x)
probs = Categorical(logits=logits)
if action is None:
action = probs.sample()
return action, probs.log_prob(action), probs.entropy(), self.critic(x)
```
|