-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHW5.py
26 lines (21 loc) · 768 Bytes
/
HW5.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
from NeuralNetworks.neuralNetwork import *
from NeuralNetworks.torchnn import *
import numpy as np
training = "Perceptron/bank-note/train.csv"
testing = "Perceptron/bank-note/test.csv"
widths = [5,10,25,50,100]
depths = [3,5,9]
reluResults = np.zeros((len(widths), len(depths)))
tanhResults = np.zeros((len(widths), len(depths)))
for i in range(len(widths)):
for j in range(len(depths)):
network = torchnn(width=widths[i], depth=depths[j])
network.train(training,2)
tanhResults[i][j] = network.test(testing)
network = torchnn(width=widths[i], depth=depths[j],tanh=True)
network.train(training,2)
tanhResults[i][j] = network.test(testing)
print("RELU")
print(reluResults)
print("TANH")
print(tanhResults)