Save_cycle

Is there a way to save final weights of each cycle after running:

learn.fit(lr*4, n_cycle=3, cycle_mult=1, cycle_len=20)

Thanks

1 Like

Yes, use the cycle_save_name param. You can use load_cycle to load them back later. See the planet_cv notebook for example.

7 Likes

Hello @jeremy,

I use cycle_save_name but it does not save my weights in tmp/340/models (cf screenshot and I checked the folder content in my terminal, too). How can I solve this issue ?

Note : before learn.fit(), I have :

def get_data(sz,bs):
    tfms = tfms_from_model(arch, sz, aug_tfms=transforms_side_on, max_zoom=1.1)
    data = ImageClassifierData.from_csv(PATH, 'train', label_csv, test_name='test', num_workers=4,
                                    val_idxs=val_idxs, suffix='.jpg', tfms=tfms, bs=bs)
    return data if sz>300 else data.resize(340, 'tmp')

data = get_data(sz,bs)
learn = ConvLearner.pretrained(arch, data, precompute=True)

Because you didn’t define cycle_len, there’s no definition of when a ‘cycle’ is finished, so it’s not saving. Try cycle_len=1, for instance.

3 Likes

Thank you @jeremy !

I keep in mind now that cycle_save_name and cycle_len work together :

learn.fit(lr, 5, cycle_len=1, cycle_save_name="MyModel")

3 Likes