-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
36 lines (25 loc) · 841 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
34
35
36
# coding: utf-8
from sklearn import metrics
import torch
from tqdm import tqdm
from dataloader import get_mnist_dataloader
from utils import create_test_data
torch.manual_seed(2999)
def main() -> None:
# DataLoader
test_dataloader = get_mnist_dataloader(_mode="test", batch_size=1)
# Device
device = "cuda:0" if torch.cuda.is_available() else "cpu"
# FFModel
model = torch.load("./models/epoch31.ckpt").eval()
# Evaluation
predicts = []
targets = []
for inputs, labels in tqdm(test_dataloader):
inputs_all_labels = create_test_data(inputs).to(device)
predict = model.predict(inputs_all_labels)
predicts.append(predict.item())
targets.append(labels.item())
print(metrics.classification_report(targets, predicts))
if __name__ == "__main__":
main()