-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheval_toy_simplex.py
More file actions
52 lines (41 loc) · 1.17 KB
/
Copy patheval_toy_simplex.py
File metadata and controls
52 lines (41 loc) · 1.17 KB
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 pytorch_lightning as pl
from torch.serialization import safe_globals
from models import MLPModel
import torch
from argparse import Namespace
from datasets import ToyDataset
# not using argparse for now
args = Namespace(
toy_num_cls=1,
toy_seq_len=4,
toy_simplex_dim=40,
hidden_dim = 512,
cls_ckpt=None,
ckpt_iterations = None,
batch_size = 32 ,
num_workers = 4 ,
prior_pseudocount = 2,
shuffle = False,
max_epochs = 5000,
expand_simplex = True,
cls_free_guidance = False,
binary_guidance = False,
num_integration_steps = 10,
limit_val_batches=1000
)
alphabet_size = 40
num_cls = 1
model = MLPModel(args, alphabet_size, num_cls, classifier = False)
required_classes = [
Namespace,
ToyDataset,
]
with safe_globals(required_classes):
checkpoint = torch.load(
'saved_models/lightning_logs/version_120/checkpoints/best-epoch=249-train_loss=5.95.ckpt',
weights_only=True
)
# Remove 'model.' prefix from all keys
state_dict = checkpoint['state_dict']
new_state_dict = {k.replace('model.', ''): v for k, v in state_dict.items()}
model.load_state_dict(new_state_dict)