MCPcopy Create free account
hub / github.com/chibohe/text_recognition_toolbox / build_pretrained_weights

Function build_pretrained_weights

program.py:84–95  ·  view source on GitHub ↗
(flags, model, optimizer)

Source from the content-addressed store, hash-verified

82
83
84def build_pretrained_weights(flags, model, optimizer):
85 # 是否加载之前训练的模型
86 pretrain_weights = flags.Global.pretrain_weights
87 to_use_device = flags.Global.device
88 if pretrain_weights and os.path.exists(pretrain_weights):
89 model, _resumed_optimizer, global_state = load_checkpoint(model, pretrain_weights, to_use_device, optimizer)
90 if flags.Global.resumed_optimizer and _resumed_optimizer is not None:
91 optimizer = _resumed_optimizer
92 else:
93 global_state = {}
94 model.apply(weight_init)
95 return model, optimizer, global_state
96
97
98def build_device(flags):

Callers 2

__init__Method · 0.90
mainFunction · 0.90

Calls 2

load_checkpointFunction · 0.90
applyMethod · 0.80

Tested by

no test coverage detected