-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathModel_Loader.py
More file actions
executable file
·79 lines (66 loc) · 2.73 KB
/
Copy pathModel_Loader.py
File metadata and controls
executable file
·79 lines (66 loc) · 2.73 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import argparse
import json
import torch
from rl_mission_planning import HetNet_tSNE
from solver import HetNet_Partial_tSNE_solver, HetNet_tSNE_solver, solver_RNN, HetNet_solver, HetNet_Partial_solver
def load_model_eval(param_path, config_path=None, tSNE=False, ablation=False, partial_type=None):
if config_path is None:
config_path = param_path[:-6]+'.config'
parser = argparse.ArgumentParser()
args = parser.parse_args()
with open(config_path, 'r') as f:
args.__dict__ = json.load(f)
print("LOADING MODEL================")
print(args)
if args.model_type == "ptrnet":
print("Pointer network is used")
model = solver_RNN(
args.embedding_size,
args.hidden_size,
args.visiting_num+args.coverage_num+args.pick_place_num+1,
2, 10)
# AM network
elif args.model_type.startswith("hetnet"):
print("HetNet is used")
if ablation:
if partial_type is None:
raise Exception("Please check partial_type")
if partial_type == 'notype' or partial_type=='nogeo':
input_size = 5
elif partial_type == 'nothing':
input_size = 2
else:
raise Exception("Please check partial_type")
if tSNE:
print("t-SNE analyzing mode(partial)")
model = HetNet_Partial_tSNE_solver(partial_type,
input_size,
args.embedding_size,
args.hidden_size,
2,
10)
else:
print("PARTIAL MODE")
model = HetNet_Partial_solver(partial_type,
input_size,
args.embedding_size,
args.hidden_size,
2,
10)
else:
if tSNE:
print("t-SNE analyzing mode")
model = HetNet_tSNE_solver(args.embedding_size,args.hidden_size,2,10)
else:
print("NORMAL MODE")
model = HetNet_solver(
args.embedding_size,
args.hidden_size,
# args.visiting_num+args.coverage_num+args.pick_place_num+1,
2, 10)
else:
raise
model.load_state_dict(torch.load(param_path))
model.eval()
print("FINSHED LOADING===========")
return model