from fastai.gen_doc.nbdoc import * from fastai.vision import * from fastai.text import * from fastai.callbacks import * from fastai.basic_train import * from fastai.train import * from fastai import callbacks path = untar_data(URLs.MNIST_SAMPLE) data = ImageDataBunch.from_folder(path) def simple_learner(): return Learner(data, simple_cnn((3,16,16,2)), metrics=[accuracy]) learn = simple_learner() learn.lr_find() learn.recorder.plot() lr = 2e-2 learn.fit_one_cycle(3, lr) learn.recorder.plot_lr(show_moms=True) learn = Learner(data, simple_cnn((3, 16, 16, 2)), metrics=[accuracy]).mixup() learn = Learner(data, simple_cnn((3, 16, 16, 2)), metrics=[accuracy, error_rate], callback_fns=[CSVLogger]) learn.fit(3) learn.csv_logger.read_logged_file() def fit_odd_shedule(learn, lr, mom): n = len(learn.data.train_dl) phases = [TrainingPhase(n, lr, mom, lr_anneal=annealing_cos), TrainingPhase(n*2, lr, mom, lr_anneal=annealing_poly(2))] sched = GeneralScheduler(learn, phases) learn.callbacks.append(sched) total_epochs = 3 learn.fit(total_epochs) learn = Learner(data, simple_cnn((3,16,16,2)), metrics=accuracy) fit_odd_shedule(learn, 1e-3, 0.9) learn.recorder.plot_lr()