--- title: Trainer keywords: fastai sidebar: home_sidebar summary: "The Trainer class inherits `tf.keras.Model` and contains everything a model needs for training. It exposes `learner.cyclic_fit` method which trains the model using **Cyclic Learning rate** discovered by Leslie Smith." description: "The Trainer class inherits `tf.keras.Model` and contains everything a model needs for training. It exposes `learner.cyclic_fit` method which trains the model using **Cyclic Learning rate** discovered by Leslie Smith." nb_path: "nbs/03_trainer.ipynb" ---
path = '/Users/aniket/Pictures/data/train'
from glob import glob
from chitra.core import IMAGENET_LABELS
def load_files(path):
return glob(f'{path}/*/images/*')
def get_label(path):
return path.split('/')[-3]
ds = Dataset(path)
model = create_cnn(tf.keras.applications.MobileNetV2(include_top=True), 1000, keras_applications=False)
trainer = Trainer(ds=ds, model=model, num_classes=1000)
trainer.compile2(2, 'sgd')
interpret = InterpretModel(False, trainer)
# path = '/data/aniket/tiny-imagenet/data/tiny-imagenet-200/train/n01641577/images/n01641577_100.JPEG'
path = '/Users/aniket/Pictures/data/train/cat/2.jpeg'
image = Image.open(path);image
interpret(image, auto_resize=False)
IMAGENET_LABELS[285]