-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqnetwork.py
35 lines (32 loc) · 1.15 KB
/
qnetwork.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import torch
import torch.nn as nn
import torch.nn.functional as F
class QNetwork(nn.Module):
""" Actor (Policy) Model."""
def __init__(self, state_size, fc1_units=64, fc2_units=64):
"""
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_unit (int): Number of nodes in first hidden layer
fc2_unit (int): Number of nodes in second hidden layer
"""
super(QNetwork,self).__init__()
self.fc1 = nn.Linear(state_size, fc1_units)
self.fc2 = nn.Linear(fc1_units, fc2_units)
#we are just going to predict the pure reward so we can handle variable number of neighbors
self.fc3 = nn.Linear(fc2_units, 1)
def forward(self,x):
# x = state
"""
Build a network that maps state -> action values.
"""
# print(f"forward, x dims {x.size()}")
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
out = self.fc3(x)
# print(out.size())
return out