-
Notifications
You must be signed in to change notification settings - Fork 0
/
function_approx.py
42 lines (32 loc) · 1.22 KB
/
function_approx.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
36
37
38
39
40
41
import torch
class Q_Network(torch.nn.Module):
def __init__(self):
super().__init__()
# Inputs to hidden layer linear transformation
self.hidden1 = torch.nn.Linear(64, 50)
self.sigmoid1 = torch.nn.Sigmoid()
# Output layer, 10 units - one for each digit
self.hidden2 = torch.nn.Linear(50, 64)
# Define sigmoid activation and softmax output
self.sigmoid2 = torch.nn.Sigmoid()
def forward(self, x):
# Pass the input tensor through each of our operations
x = self.hidden1(x)
x = self.sigmoid1(x)
x = self.hidden2(x)
x = self.sigmoid2(x)
return x
class V_Network(torch.nn.Module):
def __init__(self):
super().__init__()
# Inputs to hidden layer linear transformation
self.hidden1 = torch.nn.Linear(64, 50)
self.sigmoid1 = torch.nn.Sigmoid()
# Output layer, 10 units - one for each digit
self.hidden2 = torch.nn.Linear(50, 0)
def forward(self, x):
# Pass the input tensor through each of our operations
x = self.hidden1(x)
x = self.sigmoid1(x)
x = self.hidden2(x)
return x