Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. class Actor(nn.Module):
  2. """Actor (Policy) Model."""
  3.  
  4. def __init__(self, state_size, action_size, seed, fc_units=256):
  5. """Initialize parameters and build model.
  6. Params
  7. ======
  8. state_size (int): Dimension of each state
  9. action_size (int): Dimension of each action
  10. seed (int): Random seed
  11. fc1_units (int): Number of nodes in first hidden layer
  12. fc2_units (int): Number of nodes in second hidden layer
  13. """
  14. super(Actor, self).__init__()
  15. self.seed = torch.manual_seed(seed)
  16. self.fc1 = nn.Linear(state_size, fc_units)
  17. self.fc2 = nn.Linear(fc_units, action_size)
  18. self.reset_parameters()
  19.  
  20. def reset_parameters(self):
  21. self.fc1.weight.data.uniform_(*hidden_init(self.fc1))
  22. self.fc2.weight.data.uniform_(-3e-3, 3e-3)
  23.  
  24. def forward(self, state):
  25. """Build an actor (policy) network that maps states -> actions."""
  26. x = F.relu(self.fc1(state))
  27. return F.tanh(self.fc2(x))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement