-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
33 lines (27 loc) · 839 Bytes
/
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
import numpy as np
import pandas as pd
import seaborn as sns
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.autograd import Variable
import matplotlib.pyplot as plt
import Network as Net
PATH = "trained_model"
test_data_raw = pd.read_csv('test.csv', sep=",")
labels_test = test_data_raw['label']
test_data_raw.drop('label', axis=1, inplace=True)
test_data = test_data_raw.values
labels_test = labels_test.values
reshaped_test = []
for i in test_data:
reshaped_test.append(i.reshape(1,50,50))
test_data = np.array(reshaped_test)
test_x = torch.FloatTensor(test_data)
test_y = torch.LongTensor(labels_test.tolist())
net = Net.Network()
net.load_state_dict(torch.load(PATH))
net.eval()
predictions = net(Variable(test_x))
net.test(torch.max(predictions.data, 1)[1], test_y)