MCPcopy Index your code
hub / github.com/pytorch/pytorch / LoadModel

Function LoadModel

caffe2/python/examples/resnet50_trainer.py:137–166  ·  view source on GitHub ↗

Load pretrained model from file

(path, model, use_ideep)

Source from the content-addressed store, hash-verified

135
136
137def LoadModel(path, model, use_ideep):
138 '''
139 Load pretrained model from file
140 '''
141 log.info("Loading path: {}".format(path))
142 meta_net_def = pred_exp.load_from_db(path, 'minidb')
143 init_net = core.Net(pred_utils.GetNet(
144 meta_net_def, predictor_constants.GLOBAL_INIT_NET_TYPE))
145 predict_init_net = core.Net(pred_utils.GetNet(
146 meta_net_def, predictor_constants.PREDICT_INIT_NET_TYPE))
147
148 if use_ideep:
149 predict_init_net.RunAllOnIDEEP()
150 else:
151 predict_init_net.RunAllOnGPU()
152 if use_ideep:
153 init_net.RunAllOnIDEEP()
154 else:
155 init_net.RunAllOnGPU()
156
157 assert workspace.RunNetOnce(predict_init_net)
158 assert workspace.RunNetOnce(init_net)
159
160 # Hack: fix iteration counter which is in CUDA context after load model
161 itercnt = workspace.FetchBlob("optimizer_iteration")
162 workspace.FeedBlob(
163 "optimizer_iteration",
164 itercnt,
165 device_option=core.DeviceOption(caffe2_pb2.CPU, 0)
166 )
167
168
169def RunEpoch(

Callers 1

TrainFunction · 0.70

Calls 5

RunAllOnIDEEPMethod · 0.95
RunAllOnGPUMethod · 0.95
infoMethod · 0.80
NetMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…