-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlearnTest.py
32 lines (25 loc) · 979 Bytes
/
learnTest.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
from dataSetCreator import FeatureDataset
import torch
import torch.nn as nn
import torch.nn.functional as F
feature_set = FeatureDataset('newtestfile.csv', 1280)
train_loader = torch.utils.data.DataLoader(feature_set, batch_size=10, shuffle=True)
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
# an affine operation: y = Wx + b
self.fc1 = nn.Linear(24, 120) # 5*5 from image dimension
self.fc2 = nn.Linear(120, 84)
self.fc3 = nn.Linear(84, 10)
def forward(self, x):
# Max pooling over a (2, 2) window
x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2))
# If the size is a square, you can specify with a single number
x = F.max_pool2d(F.relu(self.conv2(x)), 2)
x = torch.flatten(x, 1) # flatten all dimensions except the batch dimension
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
return x
net = Net()
print(net)