-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
58 lines (38 loc) · 1.04 KB
/
test.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import matplotlib.pyplot as plt
from sklearn import datasets
import numpy as np
from numpy.random import normal, randint
import torch
# data loading
dataset = datasets.load_digits()
data = dataset.data
target = dataset.target
# Constructing 1 hot encoding of the labels (I'm not sure if this what they ca lled)
y = np.zeros((target.shape[0],10))
y[range(target.shape[0]),target] = 1
# train / test split
X1, X2 = data[:1600], data[1600:]
Y1, Y2 = y[:1600],y[1600:]
y_test = target[1600:]
batch = 16
print("we working baby")
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import optim
class MyNN(nn.Module):
"""A basic NN"""
def __init__(self, n1, n2, n3):
super().__init__()
self.l1 = nn.Linear(n1, n2)
self.l2 = nn.Tanh()
self.l3 = nn.Linear(n2, n3)
def forward(self, x):
"""TODO: Docstring for forward.
:f: TODO
:returns: TODO
"""
x = self.l1(x)
x = self.l2(x)
x = self.l3(x)
return x