MCPcopy Create free account
hub / github.com/pytorch/pytorch / ConstructInitTrainNetfromNet

Method ConstructInitTrainNetfromNet

caffe2/python/model_helper.py:467–491  ·  view source on GitHub ↗

r""" construct init net and train net from complete_net Inputs: net: 'core.Net' containing param_init_net and train net

(self, net)

Source from the content-addressed store, hash-verified

465 return new_net
466
467 def ConstructInitTrainNetfromNet(self, net):
468 r""" construct init net and train net from complete_net
469 Inputs:
470 net: 'core.Net' containing param_init_net and train net
471 """
472 param_op_mask = []
473 train_op_mask = []
474 for idx, op in enumerate(net.Proto().op):
475 if op.debug_info.endswith("/param_init_net"):
476 param_op_mask.append(idx)
477 else:
478 train_op_mask.append(idx)
479
480 self.param_init_net = net.Clone(
481 net.Name() + "/generated_param_init_net",
482 keep_schema=True,
483 op_id_mask=param_op_mask,
484 update_external_list=True,
485 )
486 self.net = net.Clone(
487 net.Name() + "/generated_net",
488 keep_schema=True,
489 op_id_mask=train_op_mask,
490 update_external_list=True,
491 )
492
493
494def ExtractPredictorNet(

Callers 2

test_get_complete_netMethod · 0.95

Calls 4

CloneMethod · 0.80
ProtoMethod · 0.45
appendMethod · 0.45
NameMethod · 0.45

Tested by 2

test_get_complete_netMethod · 0.76