Skip to content

Instantly share code, notes, and snippets.

@pyliaorachel
Created June 15, 2018 05:00
Show Gist options
  • Save pyliaorachel/b59a38eb4b4d82507ed5de4dd5da86fe to your computer and use it in GitHub Desktop.
Save pyliaorachel/b59a38eb4b4d82507ed5de4dd5da86fe to your computer and use it in GitHub Desktop.
OpenAI Gym CartPole - Deep Q-Learning (create net)
class Net(nn.Module):
def __init__(self, n_states, n_actions, n_hidden):
super(Net, self).__init__()
# 輸入層 (state) 到隱藏層,隱藏層到輸出層 (action)
self.fc1 = nn.Linear(n_states, n_hidden)
self.out = nn.Linear(n_hidden, n_actions)
def forward(self, x):
x = self.fc1(x)
x = F.relu(x) # ReLU activation
actions_value = self.out(x)
return actions_value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment