name = 'mdl_res34localpool_168168_lessaugs_mucm_fixed_adam_onecycle_fld3of5'

logger = CSVLogger(learn, name)

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

# learn.fit_one_cycle(
#     100,
#     max_lr=0.001,
#     wd=0.0,
#     pct_start=0.0,
#     div_factor=100.,
#     #final_div=100.,
#     callbacks=[logger, SaveModelCallback(learn, monitor='metric_tot', mode='max', name=name), MuCmCallback(learn)]
# )

learn.fit(100,
          lr=0.001,
          wd=0.0,
          callbacks=[
              logger,
              SaveModelCallback(learn,
                                monitor='metric_tot',
                                mode='max',
                                name=name),
              MuCmCallback(learn),
              ReduceLROnPlateauCallback(learn,
                                        patience=10,
                                        factor=0.5,
                                        min_lr=.00001)
          ])
# =========================================================================================

classifier = mdl_ResDenHybrid()

class SGD_m5(SGD):
    def __init__(self, *args, **kwargs):
        super().__init__(momentum=0.5, *args, **kwargs)

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

name = 'mdl_ResDenHybrid_sgd_lessaugs_mucm_fixed_raw_onecycle_fld1of5'

logger = CSVLogger(learn, name)

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

learn.fit_one_cycle(
    160,
    max_lr=0.05,
    wd=0.0,
    pct_start=0.0,
    div_factor=50.,
    final_div=100.,
    callbacks=[logger, SaveModelCallback(learn, monitor='metric_tot', mode='max', name=name), MuCmCallback(learn)]
)