-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.py
45 lines (25 loc) · 909 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
37
38
39
40
41
42
43
44
from utils import SQLDataset,collate_fn
from wordembedding import WordEmbedding
from torch.utils.data import Dataset,DataLoader
from model import Model
from extract_vocab import load_word_emb
import torch
import numpy as np
from utils import test_model
import torch.nn as nn
import torch.optim as optim
filename= 'glove/glove.6B.50d.txt'
#checkpoint_name = 'saved_models/agg_model.pth'
test_entry = (None,None,True)
N_word= 50
batch_size = 10
hidden_dim = 100
n_epochs = 5
word_embed = load_word_emb(filename)
test = SQLDataset('test')
test_loader = DataLoader(test,batch_size=batch_size,shuffle=True,collate_fn=collate_fn)
word_emb = WordEmbedding(N_word,word_embed)
model = Model(hidden_dim,N_word,word_emb)
#model.agg_predictor.load_state_dict( torch.load('saved_model/agg_predictor.pth') )
optimizer = optim.Adam(model.parameters(),lr=0.01)
test_model(model,test_loader,test_entry )