MCPcopy Create free account
hub / github.com/AgentMaker/Paddle-RLBooks / Actor

Class Actor

ddpg/model.py:5–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import paddle.nn.functional as F
4
5class Actor(nn.Layer):
6 def __init__(self, state_dim, action_dim, max_action):
7 super(Actor, self).__init__()
8
9 self.l1 = nn.Linear(state_dim, 400)
10 self.l2 = nn.Linear(400, 300)
11 self.l3 = nn.Linear(300, action_dim)
12
13 self.max_action = max_action
14
15 def forward(self, state):
16 a = F.relu(self.l1(state))
17 a = F.relu(self.l2(a))
18
19 return self.max_action * F.tanh(self.l3(a))
20
21 def select_action(self, state):
22 state = paddle.to_tensor(state.reshape(1, -1)).astype('float32')
23 return self.forward(state).numpy()[0]
24
25class Critic(nn.Layer):
26 def __init__(self, state_dim, action_dim):

Callers 1

train.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected