<jupyter_start><jupyter_text>After a bad first attempt at creating an image classification model, I trained a model on the MNIST database of handwritten digits this time around. This post is actually a jupyter notebook, which you can find [here](https://github.com/akshathkothari/akshathkothari.github.io/tree/master/_jupyter).  The Project<jupyter_code>from fastai.vision import *
path = Path('/home/jupyter/projects/data/mnist-handwritten-digits')<jupyter_output><empty_output><jupyter_text>There was no need of downloading the images this time - I used images provided at the [fastai website](https://course.fast.ai/datasets) from the [MNIST database of handwritten digits](http://yann.lecun.com/exdb/mnist/).  View Data<jupyter_code>np.random.seed(2)
data = ImageDataBunch.from_folder(path, train="training", test="testing", valid_pct=0.2, ds_tfms=get_transforms(do_flip=False), size=24).normalize(mnist_stats)
data.classes, data.c, len(data.train_ds), len(data.valid_ds)
data.show_batch(rows = 3, figsize=(8,6))<jupyter_output><empty_output><jupyter_text>Train Model<jupyter_code>learn = cnn_learner(data, models.resnet34, metrics=error_rate)
learn.fit_one_cycle(4)
learn.save('stage-1')<jupyter_output><empty_output><jupyter_text>Interpretation<jupyter_code>interp = ClassificationInterpretation.from_learner(learn)
interp.plot_confusion_matrix()
interp.plot_top_losses(9, figsize=(7, 6), heatmap=False)<jupyter_output><empty_output><jupyter_text>Fine Tuning<jupyter_code>learn.unfreeze()
learn.fit_one_cycle(1)
learn.lr_find()
learn.recorder.plot()
learn.unfreeze()
learn.fit_one_cycle(2, max_lr=slice(1e-6,1e-4))
learn.save('stage-2')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12739234449760767, 'fraction_numerical': 0.013157894736842105, 'mean_word_length': 8.614942528735632, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '189209', 'license': 'MIT', 'n_tokens_mistral': 623, 'n_tokens_neox': 608, 'n_words': 103, 'path': 'fastai-practical-deep-learning/mnist-handwritten-digits.ipynb', 'repo_name': 'ricekot/learning', 'size': '1672'}