From 14523bb0307f30abfb417763377b5c6d2817a7a5 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 15 Jun 2020 13:18:39 -0700 Subject: [PATCH] FP16 to FP32 ckpt load --- train.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/train.py b/train.py index b615b47..33fa8af 100644 --- a/train.py +++ b/train.py @@ -112,8 +112,8 @@ def train(hyp): # load model 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) except KeyError as e: s = "%s is not compatible with %s. Specify --weights '' or specify a --cfg compatible with %s." \