Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Actor(nn.Module):
- """Actor (Policy) Model."""
- def __init__(self, state_size, action_size, seed, fc_units=256):
- """Initialize parameters and build model.
- Params
- ======
- state_size (int): Dimension of each state
- action_size (int): Dimension of each action
- seed (int): Random seed
- fc1_units (int): Number of nodes in first hidden layer
- fc2_units (int): Number of nodes in second hidden layer
- """
- super(Actor, self).__init__()
- self.seed = torch.manual_seed(seed)
- self.fc1 = nn.Linear(state_size, fc_units)
- self.fc2 = nn.Linear(fc_units, action_size)
- self.reset_parameters()
- def reset_parameters(self):
- self.fc1.weight.data.uniform_(*hidden_init(self.fc1))
- self.fc2.weight.data.uniform_(-3e-3, 3e-3)
- def forward(self, state):
- """Build an actor (policy) network that maps states -> actions."""
- x = F.relu(self.fc1(state))
- return F.tanh(self.fc2(x))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement