-
Notifications
You must be signed in to change notification settings - Fork 0
/
__eval__.py
52 lines (40 loc) · 1.06 KB
/
__eval__.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
import torch
from torch.utils.data import DataLoader
from dataset import TextDataset
from eval import test_perplexity
def main(
cache_dir="./cache/datasets",
device="cuda:0"
):
model = torch.load("saved/final").to(device)
dataloader = DataLoader(
TextDataset(
name="scientific_papers",
cache_dir=cache_dir,
split="test",
seq_len=512,
block_len=5,
device=device,
sep_padding=False,
),
batch_size=8,
)
ppl = test_perplexity(model, dataloader, device)
print("No [SEP] Perplexity: ", ppl)
dataloader = DataLoader(
TextDataset(
name="scientific_papers",
cache_dir=cache_dir,
split="test",
seq_len=512,
block_len=5,
device=device,
sep_padding=True,
sep_padding_prob=0.7
),
batch_size=8,
)
ppl = test_perplexity(model, dataloader, device)
print("[SEP] Perplexity: ", ppl)
if __name__ == "__main__":
main()