MCPcopy
hub / github.com/hanzhanggit/StackGAN / load_model

Function load_model

misc/skipthoughts.py:32–72  ·  view source on GitHub ↗

Load the model with saved tables

()

Source from the content-addressed store, hash-verified

30
31
32def load_model():
33 """
34 Load the model with saved tables
35 """
36 # Load model options
37 print 'Loading model parameters...'
38 with open('%s.pkl'%path_to_umodel, 'rb') as f:
39 uoptions = pkl.load(f)
40 with open('%s.pkl'%path_to_bmodel, 'rb') as f:
41 boptions = pkl.load(f)
42
43 # Load parameters
44 uparams = init_params(uoptions)
45 uparams = load_params(path_to_umodel, uparams)
46 utparams = init_tparams(uparams)
47 bparams = init_params_bi(boptions)
48 bparams = load_params(path_to_bmodel, bparams)
49 btparams = init_tparams(bparams)
50
51 # Extractor functions
52 print 'Compiling encoders...'
53 embedding, x_mask, ctxw2v = build_encoder(utparams, uoptions)
54 f_w2v = theano.function([embedding, x_mask], ctxw2v, name='f_w2v')
55 embedding, x_mask, ctxw2v = build_encoder_bi(btparams, boptions)
56 f_w2v2 = theano.function([embedding, x_mask], ctxw2v, name='f_w2v2')
57
58 # Tables
59 print 'Loading tables...'
60 utable, btable = load_tables()
61
62 # Store everything we need in a dictionary
63 print 'Packing up...'
64 model = {}
65 model['uoptions'] = uoptions
66 model['boptions'] = boptions
67 model['utable'] = utable
68 model['btable'] = btable
69 model['f_w2v'] = f_w2v
70 model['f_w2v2'] = f_w2v2
71
72 return model
73
74
75def load_tables():

Callers

nothing calls this directly

Calls 7

init_paramsFunction · 0.85
load_paramsFunction · 0.85
init_tparamsFunction · 0.85
init_params_biFunction · 0.85
build_encoderFunction · 0.85
build_encoder_biFunction · 0.85
load_tablesFunction · 0.85

Tested by

no test coverage detected