Browse Source

FP16 to FP32 ckpt load

5.0
Glenn Jocher 4 years ago
parent
commit
14523bb030
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      train.py

+ 2
- 2
train.py View File



# load model # load model
try: try:
ckpt['model'] = \
{k: v for k, v in ckpt['model'].state_dict().items() if model.state_dict()[k].numel() == v.numel()}
ckpt['model'] = {k: v for k, v in ckpt['model'].float().state_dict().items()
if model.state_dict()[k].shape == v.shape} # to FP32, filter
model.load_state_dict(ckpt['model'], strict=False) model.load_state_dict(ckpt['model'], strict=False)
except KeyError as e: except KeyError as e:
s = "%s is not compatible with %s. Specify --weights '' or specify a --cfg compatible with %s." \ s = "%s is not compatible with %s. Specify --weights '' or specify a --cfg compatible with %s." \

Loading…
Cancel
Save