Created
June 15, 2018 05:00
-
-
Save pyliaorachel/b59a38eb4b4d82507ed5de4dd5da86fe to your computer and use it in GitHub Desktop.
OpenAI Gym CartPole - Deep Q-Learning (create net)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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