示例#1
0
classifier.load_state_dict(weight, strict=False)

learn = Learner(
    data_bunch,
    classifier,
    loss_func=Loss_combine_weighted_v2(),
    opt_func=SGD,
    metrics=[Metric_grapheme(), Metric_vowel(), Metric_consonant(), Metric_tot()]
)

name = 'pytorch_model_simple50'

logger = CSVLogger(learn, name)

# =========================================================================================================================

learn.fit_one_cycle(
    cyc_len=160, max_lr=.01, wd=0.0, moms=0.5, div_factor=25, final_div=100, pct_start=0.015,
    callbacks=[logger, SaveModelCallback(learn, monitor='metric_tot', mode='max', name=name), MixUpCallback(learn)],
)

# learn.fit(
#     160,
#     lr=.01, wd=0.00001,
#     callbacks=[
#         logger, 
#         SaveModelCallback(learn, monitor='metric_tot', mode='max', name=name), 
#         MixUpCallback(learn),
#         ReduceLROnPlateauCallback(learn, patience=10, factor=0.5, min_lr=.0001)
#     ]
# )
learn.clip_grad = 1.0
# learn.split([classifier.predictor.lin_layers])
learn.unfreeze()

# In[9]:

learn.fit_one_cycle(96,
                    max_lr=1e-2,
                    wd=0.,
                    pct_start=0.0,
                    div_factor=100,
                    callbacks=[
                        logger,
                        SaveModelCallback(learn,
                                          monitor='metric_tot',
                                          mode='max',
                                          name=logging_name),
                        MixUpCallback(learn)
                    ])

# learn.fit(
#     160,
#     lr=.01,
#     wd=0.,
#     callbacks=[
#         logger,
#         SaveModelCallback(learn, monitor='metric_tot', mode='max', name=logging_name),
#         ReduceLROnPlateauCallback(learn, patience=10, factor=.1, min_lr=1e-5),
#         MixUpCallback(learn, alpha=.8),
#     ]
# )

# ==================================================================

classifier = Seresnext50MishFrac()

logging_name = 'new_baseline_seresnext50_Mish_Frac'

learn = Learner(
    data_bunch,
    classifier,
    loss_func=Loss_combine_weighted_v2(),
    opt_func=Over9000,
    metrics=[Metric_grapheme(), Metric_vowel(), Metric_consonant(), Metric_tot()]
)

logger = CSVLogger(learn, logging_name)

learn.clip_grad = 1.0

# ==================================================================

learn.fit_one_cycle(
    120,
    max_lr=1e-2,
    wd=0.,
    pct_start=0.0,
    div_factor=100,
    callbacks=[logger, SaveModelCallback(learn, monitor='metric_tot', mode='max', name=logging_name), MixUpCallback(learn, alpha=1)]
)
示例#4
0
learn = Learner(data_bunch,
                classifier,
                loss_func=Loss_combine_weighted(),
                opt_func=Over9000,
                metrics=[
                    Metric_grapheme(),
                    Metric_vowel(),
                    Metric_consonant(),
                    Metric_tot()
                ])

logger = CSVLogger(learn, logging_name)

learn.clip_grad = 1.0

# ==================================================================

learn.fit_one_cycle(64,
                    max_lr=1e-2,
                    wd=0.,
                    pct_start=0.0,
                    div_factor=100,
                    callbacks=[
                        logger,
                        SaveModelCallback(learn,
                                          monitor='metric_tot',
                                          mode='max',
                                          name=logging_name),
                        MixUpCallback(learn, alpha=1.)
                    ])