Hi.
I trained model on my own images and at the third epoch it hit 100% accuracy:
Is there a way to load weights from that particular epoch?
Hi.
I trained model on my own images and at the third epoch it hit 100% accuracy:
Is there a way to load weights from that particular epoch?
You can add a Callback, e.g. like the following:
learner.callback_fns.append(partial(callbacks.SaveModelCallback,
monitor='error_rate',
mode='min',
name='checkpoint'))
Thanks! Exactly what I need.
How did you end up loading them into your Learner?
I see the typical learn.export()
and load_learner()
returns a TabularLearner
class instance
whereas loading an epoch .pth
files returns an OrderedDict
.
learn.export()
model_2 = torch.load(f'{model_dir}/2_{REF}_LEARNER_MODEL.pt')
model_2
TabularModel(
(embeds): ModuleList(
(0): Embedding(3, 3)
(1): Embedding(4, 3)
(2): Embedding(2, 2)
(3): Embedding(2, 2)
(4): Embedding(2, 2)
(5): Embedding(3, 3)
(6): Embedding(3, 3)
(7): Embedding(3, 3)
(8): Embedding(3, 3)
(9): Embedding(3, 3)
)
(emb_drop): Dropout(p=0.0, inplace=False)
...
vs
SaveCallback Model
model = torch.load(f'{model_dir}/epoch_0.pth')
model
OrderedDict([('embeds.0.weight',
tensor([[-0.0072, -0.0023, -0.0089],
[ 0.0136, -0.0070, -0.0010],
[ 0.0100, 0.0107, -0.0069]])),
('embeds.1.weight',
tensor([[ 0.0116, 0.0093, -0.0203],
[ 0.0150, -0.0255, -0.0120],
[-0.0375, -0.0029, 0.0371],
[-0.0033, 0.0486, -0.0059]])),
('embeds.2.weight',
tensor([[ 0.0202, 0.0329],
[-0.0139, -0.0045]])),
('embeds.3.weight',
tensor([[-0.0002, 0.0002],
[-0.0092, -0.0142]])),
('embeds.4.weight',
tensor([[-0.0140, -0.0112],
[-0.0056, -0.0078]])),