├── .gitattributes ├── .gitignore ├── CODE-OF-CONDUCT.md ├── LICENSE ├── Makefile ├── README.md ├── azure-pipelines.yml ├── data ├── .gitignore ├── adult_sample.tgz ├── imdb_sample.tgz ├── mnist_sample.tgz └── movie_lens_sample.tgz ├── dev ├── .gitignore ├── .root ├── 00_test.ipynb ├── 01_core_foundation.ipynb ├── 01a_core_utils.ipynb ├── 01b_core_dispatch.ipynb ├── 01c_core_transform.ipynb ├── 02_core_script.ipynb ├── 03_torchcore.ipynb ├── 03a_layers.ipynb ├── 04_data_load.ipynb ├── 05_data_core.ipynb ├── 06_data_transforms.ipynb ├── 07_data_block.ipynb ├── 08_vision_core.ipynb ├── 09_vision_augment.ipynb ├── 09a_vision_data.ipynb ├── 09b_vision_utils.ipynb ├── 10_pets_tutorial.ipynb ├── 11_vision_models_xresnet.ipynb ├── 12_optimizer.ipynb ├── 13_learner.ipynb ├── 13a_metrics.ipynb ├── 14_callback_schedule.ipynb ├── 14a_callback_data.ipynb ├── 15_callback_hook.ipynb ├── 15a_vision_models_unet.ipynb ├── 16_callback_progress.ipynb ├── 17_callback_tracker.ipynb ├── 18_callback_fp16.ipynb ├── 19_callback_mixup.ipynb ├── 20_interpret.ipynb ├── 20a_distributed.ipynb ├── 21_vision_learner.ipynb ├── 22_tutorial_imagenette.ipynb ├── 23_tutorial_transfer_learning.ipynb ├── 30_text_core.ipynb ├── 31_text_data.ipynb ├── 32_text_models_awdlstm.ipynb ├── 33_text_models_core.ipynb ├── 34_callback_rnn.ipynb ├── 35_tutorial_wikitext.ipynb ├── 36_text_models_qrnn.ipynb ├── 37_text_learner.ipynb ├── 38_tutorial_ulmfit.ipynb ├── 40_tabular_core.ipynb ├── 41_tabular_model.ipynb ├── 50_data_block_examples.ipynb ├── 60_medical_imaging.ipynb ├── 65_medical_text.ipynb ├── 70_callback_wandb.ipynb ├── 71_callback_tensorboard.ipynb ├── 90_xse_resnext.ipynb ├── 95_index.ipynb ├── 96_data_external.ipynb ├── 97_utils_test.ipynb ├── _09a_rect_augment.ipynb ├── _40_tabular_core_old.ipynb ├── _42_tabular_rapids.ipynb ├── _minimal_show.ipynb ├── _notebook2jekyll.ipynb ├── _whl2conda.ipynb ├── config.yml ├── course │ ├── lesson1-pets.ipynb │ ├── lesson2-download.ipynb │ ├── lesson2-sgd.ipynb │ ├── lesson3-camvid.ipynb │ ├── lesson3-head-pose.ipynb │ ├── lesson3-imdb.ipynb │ └── lesson3-planet.ipynb ├── examples │ ├── camvid.ipynb │ ├── train_imagenette.py │ └── ulmfit.ipynb ├── fastai2 │ ├── __init__.py │ ├── _nbdev.py │ ├── basics.py │ ├── callback │ │ ├── __init__.py │ │ ├── all.py │ │ ├── data.py │ │ ├── fp16.py │ │ ├── hook.py │ │ ├── mixup.py │ │ ├── progress.py │ │ ├── rnn.py │ │ ├── schedule.py │ │ ├── tensorboard.py │ │ ├── tracker.py │ │ └── wandb.py │ ├── core │ │ ├── __init__.py │ │ ├── all.py │ │ ├── dispatch.py │ │ ├── foundation.py │ │ ├── imports.py │ │ ├── script.py │ │ ├── transform.py │ │ └── utils.py │ ├── distributed.py │ ├── fp16_utils.py │ ├── interpret.py │ ├── launch.py │ ├── layers.py │ ├── learner.py │ ├── medical │ │ ├── __init__.py │ │ ├── imaging.py │ │ └── text.py │ ├── metrics.py │ ├── notebook │ │ ├── __init__.py │ │ ├── autogen.tpl │ │ ├── core.py │ │ ├── export.py │ │ ├── export2html.py │ │ ├── hide.tpl │ │ ├── index.txt │ │ ├── index_pytorch.txt │ │ ├── jekyll-md.tpl │ │ ├── jekyll.tpl │ │ ├── showdoc.py │ │ └── test.py │ ├── optimizer.py │ ├── tabular │ │ ├── __init__.py │ │ ├── core.py │ │ ├── model.py │ │ └── rapids.py │ ├── test.py │ ├── test_utils.py │ ├── text │ │ ├── __init__.py │ │ ├── all.py │ │ ├── core.py │ │ ├── data.py │ │ ├── learner.py │ │ └── models │ │ │ ├── __init__.py │ │ │ ├── awdlstm.py │ │ │ ├── bwd_forget_mult_cuda.cpp │ │ │ ├── bwd_forget_mult_cuda_kernel.cu │ │ │ ├── core.py │ │ │ ├── forget_mult_cuda.cpp │ │ │ ├── forget_mult_cuda_kernel.cu │ │ │ └── qrnn.py │ ├── torch_basics.py │ ├── torch_core.py │ ├── torch_imports.py │ ├── version.py │ └── vision │ │ ├── __init__.py │ │ ├── all.py │ │ ├── augment.py │ │ ├── core.py │ │ ├── data.py │ │ ├── learner.py │ │ ├── models │ │ ├── __init__.py │ │ ├── all.py │ │ ├── unet.py │ │ ├── xresnet.py │ │ └── xsenet.py │ │ └── utils.py ├── files │ ├── .gitignore │ └── test.txt.bz2 ├── images │ ├── Mixed_precision.jpeg │ ├── half.png │ ├── half_representation.png │ ├── mnist3.png │ ├── pixelshuffle.png │ ├── puppy.jpg │ └── sample.dcm ├── posts │ ├── .gitignore │ └── 2019-08-06-delegation.ipynb ├── tools │ ├── build_docs │ ├── diff_nb_script │ ├── fastai2 │ ├── notebook2script │ ├── script2notebook │ ├── sidebar_data.py │ └── test_nbs └── train_wt2.py ├── dev_nb ├── .gitattributes ├── .gitignore ├── 001a_nn_basics.ipynb ├── 001b_fit.ipynb ├── 002_images.ipynb ├── 002b_augment_training.ipynb ├── 002c_warp.ipynb ├── 003_rect_square_crop.ipynb ├── 004_callbacks.ipynb ├── 004a_discriminative_lr.ipynb ├── 004b_mixed_precision.ipynb ├── 005_dogs_cats.ipynb ├── 005a_interpretation.ipynb ├── 005b_planet.ipynb ├── 006_carvana.ipynb ├── 006a_unet.ipynb ├── 006b_pascal.ipynb ├── 006c_camvid.ipynb ├── 007_wikitext_2.ipynb ├── 007a_imdb_preparation.ipynb ├── 007b_imdb_classifier.ipynb ├── 008_movie_lens.ipynb ├── 009_rossmann.ipynb ├── 099_tfm_coords.ipynb ├── 100_add_metrics.ipynb ├── 101_devise.ipynb ├── 102a_coco.ipynb ├── 103_wgan.ipynb ├── 103_wganF.ipynb ├── 104_data_block_API.ipynb ├── 104a_camvid.ipynb ├── 104b_pets_planets.ipynb ├── 104c_single_image_pred.ipynb ├── 104d_show_batch.ipynb ├── 105_refactor_text_data.ipynb ├── 106_cyclegan.ipynb ├── 110_transformer_pretrained.ipynb ├── 200_datablock_config.ipynb ├── 200_datablock_config_jh.ipynb ├── 201_batch_transform.ipynb ├── 202_tokenizing.ipynb ├── 202a_tokenize_benchmark.ipynb ├── BugAD.ipynb ├── Loss_func2Activ.ipynb ├── autoreload │ ├── any-module-fail.ipynb │ └── fastai-fail.ipynb ├── discriminator-digit.ipynb ├── discriminator-exp.ipynb ├── discriminator.ipynb ├── discriminator1.ipynb ├── dogscats.py ├── enhance-wsdr.ipynb ├── enhance.ipynb ├── exp ├── experiments │ ├── .gitattributes │ ├── Caltech101bug.ipynb │ ├── README.md │ ├── build_imgnet_local_small.ipynb │ ├── caltech101.ipynb │ ├── check_classifier.ipynb │ ├── cifar10_comparison_pipelines.ipynb │ ├── cifar_check.ipynb │ ├── comp_gs_numpy_torch.ipynb │ ├── dogs_cats.ipynb │ ├── imdb_classification.ipynb │ ├── keras_lesson1.ipynb │ ├── lm_checks.ipynb │ ├── pipelines_speed_comp.ipynb │ ├── random_resize_crop.ipynb │ ├── rossmann.ipynb │ ├── tfm_refactor.ipynb │ └── wikitext103-qrnn.ipynb ├── forget_mult.py ├── get_all.ipynb ├── imagenette.ipynb ├── imgs │ ├── clusters.png │ └── devise_arch.png ├── lesson7-wgan.ipynb ├── mem_leaks │ ├── .gitattributes │ ├── OOM_on_fit_recover.ipynb │ ├── locals_leak_on_exc.ipynb │ ├── vision_basic_train.ipynb │ └── vision_basic_train_peak.ipynb ├── mnist_sample.ipynb ├── mnist_sample.py ├── models.py ├── nb_001a.py ├── nb_001b.py ├── nb_002.py ├── nb_002b.py ├── nb_002c.py ├── nb_003.py ├── nb_004.py ├── nb_004a.py ├── nb_004b.py ├── nb_005.py ├── nb_005a.py ├── nb_005b.py ├── nb_006.py ├── nb_006a.py ├── nb_006b.py ├── nb_007.py ├── nb_007a.py ├── nb_007b.py ├── nb_008.py ├── nb_009.py ├── nb_102a.py ├── nb_104.py ├── nb_104a.py ├── nb_104b.py ├── nb_200.py ├── new_callbacks.ipynb ├── notebook2script.py ├── qrnn.py ├── snapshot │ ├── .gitattributes │ ├── 001a_nn_basics.ipynb │ ├── 002_images.ipynb │ ├── 005_dogs_cats.ipynb │ ├── 006_carvana.ipynb │ ├── 006c_camvid.ipynb │ ├── 007b_imdb_classifier.ipynb │ ├── README.md │ ├── cifar_check.ipynb │ ├── mnist_sample.ipynb │ └── stl-10.ipynb ├── stl-10.ipynb ├── translation_pretrained.ipynb ├── wikitext_103.ipynb ├── x_003a_rect_images.ipynb ├── x_003b_rect_training.ipynb ├── x_003c_random_resized_crop.ipynb ├── x_004b_implement_fast_progress.ipynb ├── x_006d_imgnet.ipynb └── x_alternative_progress_bar.ipynb ├── docs ├── .gitignore ├── Gemfile ├── Gemfile.lock ├── _config.yml ├── _data │ ├── alerts.yml │ ├── definitions.yml │ ├── glossary.yml │ ├── sidebars │ │ └── home_sidebar.yml │ ├── tags.yml │ ├── terms.yml │ └── topnav.yml ├── _includes │ ├── archive.html │ ├── callout.html │ ├── footer.html │ ├── google_analytics.html │ ├── head.html │ ├── head_print.html │ ├── image.html │ ├── important.html │ ├── initialize_shuffle.html │ ├── inline_image.html │ ├── links.html │ ├── note.html │ ├── search_google_custom.html │ ├── search_simple_jekyll.html │ ├── sidebar.html │ ├── tip.html │ ├── toc.html │ ├── topnav.html │ └── warning.html ├── _layouts │ ├── default.html │ ├── default_print.html │ ├── none.html │ ├── page.html │ └── page_print.html ├── augmentation.html ├── callback.data.html ├── callback.fp16.html ├── callback.hook.html ├── callback.mixup.html ├── callback.progress.html ├── callback.rnn.html ├── callback.schedule.html ├── callback.tensorboard.html ├── callback.tracker.html ├── callback.wandb.html ├── core.dispatch.html ├── core.foundation.html ├── core.script.html ├── core.transform.html ├── core.utils.html ├── css │ ├── bootstrap.min.css │ ├── boxshadowproperties.css │ ├── customstyles.css │ ├── font-awesome.min.css │ ├── fonts │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.svg │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ └── fontawesome-webfont.woff2 │ ├── modern-business.css │ ├── printstyles.css │ ├── syntax.css │ ├── theme-blue.css │ └── theme-green.css ├── data.block.examples.html ├── data.block.html ├── data.core.html ├── data.external.html ├── data.load.html ├── data.transforms.html ├── distributed.html ├── feed.xml ├── fonts │ ├── FontAwesome.otf │ ├── fontawesome-webfont.eot │ ├── fontawesome-webfont.svg │ ├── fontawesome-webfont.ttf │ ├── fontawesome-webfont.woff │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 ├── images │ ├── company_logo.png │ ├── company_logo_big.png │ ├── favicon.ico │ ├── half.png │ ├── pixelshuffle.png │ └── workflowarrow.png ├── index.html ├── interpret.html ├── js │ ├── customscripts.js │ ├── jekyll-search.js │ ├── jquery.ba-throttle-debounce.min.js │ ├── jquery.navgoco.min.js │ ├── jquery.shuffle.min.js │ └── toc.js ├── layers.html ├── learner.html ├── licenses │ ├── LICENSE │ └── LICENSE-BSD-NAVGOCO.txt ├── medical.imaging.html ├── medical.text.html ├── metrics.html ├── notebook.core.html ├── notebook.export.html ├── notebook.export2html.html ├── notebook.showdoc.html ├── notebook.test.html ├── optimizer.html ├── pets.tutorial.html ├── rect.augment.html ├── search.json ├── sitemap.xml ├── synth.learner.html ├── tabular.core.html ├── tabular.model.html ├── tabular.rapids.html ├── test.html ├── text.core.html ├── text.data.html ├── text.learner.html ├── text.models.awdlstm.html ├── text.models.core.html ├── text.models.qrnn.html ├── tooltips.json ├── torchcore.html ├── tutorial.imagenette.html ├── tutorial.transfer.learning.html ├── tutorial.ulmfit.html ├── tutorial.wikitext.html ├── utils.test.html ├── vision.augment.html ├── vision.core.html ├── vision.data.html ├── vision.learner.html ├── vision.models.unet.html ├── vision.models.xresnet.html ├── vision.utils.html └── xse.resnext.html ├── environment.yml ├── fastai2 ├── setup.py ├── swift ├── .gitignore ├── 00_load_data.ipynb ├── 00a_intro_and_float.ipynb ├── 01_matmul.ipynb ├── 01a_fastai_layers.ipynb ├── 02_fully_connected.ipynb ├── 02a_why_sqrt5.ipynb ├── 02b_initializing.ipynb ├── 02c_autodiff.ipynb ├── 03_minibatch_training.ipynb ├── 04_callbacks.ipynb ├── 05_anneal.ipynb ├── 05b_early_stopping.ipynb ├── 06_cuda.ipynb ├── 07_batchnorm.ipynb ├── 07b_batchnorm_lesson.ipynb ├── 08_data_block.ipynb ├── 08a_heterogeneous_dictionary.ipynb ├── 08b_data_block_opencv.ipynb ├── 08c_data_block-lightlyfunctional.ipynb ├── 08c_data_block_generic.ipynb ├── 09_optimizer.ipynb ├── 10_mixup_ls.ipynb ├── 11_imagenette.ipynb ├── FastaiNotebook_00_load_data │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_00_load_data │ │ └── 00_load_data.swift ├── FastaiNotebook_01_matmul │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_01_matmul │ │ ├── 00_load_data.swift │ │ └── 01_matmul.swift ├── FastaiNotebook_01a_fastai_layers │ ├── Package.resolved │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_01a_fastai_layers │ │ ├── 00_load_data.swift │ │ ├── 01_matmul.swift │ │ └── 01a_fastai_layers.swift ├── FastaiNotebook_02_fully_connected │ ├── Package.resolved │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_02_fully_connected │ │ ├── 00_load_data.swift │ │ ├── 01_matmul.swift │ │ ├── 01a_fastai_layers.swift │ │ └── 02_fully_connected.swift ├── FastaiNotebook_02a_why_sqrt5 │ ├── Package.resolved │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_02a_why_sqrt5 │ │ ├── 00_load_data.swift │ │ ├── 01_matmul.swift │ │ ├── 01a_fastai_layers.swift │ │ ├── 02_fully_connected.swift │ │ └── 02a_why_sqrt5.swift ├── FastaiNotebook_03_minibatch_training │ ├── Package.resolved │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_03_minibatch_training │ │ ├── 00_load_data.swift │ │ ├── 01_matmul.swift │ │ ├── 01a_fastai_layers.swift │ │ ├── 02_fully_connected.swift │ │ ├── 02a_why_sqrt5.swift │ │ └── 03_minibatch_training.swift ├── FastaiNotebook_04_callbacks │ ├── Package.resolved │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_04_callbacks │ │ ├── 00_load_data.swift │ │ ├── 01_matmul.swift │ │ ├── 01a_fastai_layers.swift │ │ ├── 02_fully_connected.swift │ │ ├── 02a_why_sqrt5.swift │ │ ├── 03_minibatch_training.swift │ │ └── 04_callbacks.swift ├── FastaiNotebook_05_anneal │ ├── Package.resolved │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_05_anneal │ │ ├── 00_load_data.swift │ │ ├── 01_matmul.swift │ │ ├── 01a_fastai_layers.swift │ │ ├── 02_fully_connected.swift │ │ ├── 02a_why_sqrt5.swift │ │ ├── 03_minibatch_training.swift │ │ ├── 04_callbacks.swift │ │ └── 05_anneal.swift ├── FastaiNotebook_05b_early_stopping │ ├── Package.resolved │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_05b_early_stopping │ │ ├── 00_load_data.swift │ │ ├── 01_matmul.swift │ │ ├── 01a_fastai_layers.swift │ │ ├── 02_fully_connected.swift │ │ ├── 02a_why_sqrt5.swift │ │ ├── 03_minibatch_training.swift │ │ ├── 04_callbacks.swift │ │ ├── 05_anneal.swift │ │ └── 05b_early_stopping.swift ├── FastaiNotebook_06_cuda │ ├── Package.resolved │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_06_cuda │ │ ├── 00_load_data.swift │ │ ├── 01_matmul.swift │ │ ├── 01a_fastai_layers.swift │ │ ├── 02_fully_connected.swift │ │ ├── 02a_why_sqrt5.swift │ │ ├── 03_minibatch_training.swift │ │ ├── 04_callbacks.swift │ │ ├── 05_anneal.swift │ │ ├── 05b_early_stopping.swift │ │ └── 06_cuda.swift ├── FastaiNotebook_07_batchnorm │ ├── Package.resolved │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_07_batchnorm │ │ ├── 00_load_data.swift │ │ ├── 01_matmul.swift │ │ ├── 01a_fastai_layers.swift │ │ ├── 02_fully_connected.swift │ │ ├── 02a_why_sqrt5.swift │ │ ├── 03_minibatch_training.swift │ │ ├── 04_callbacks.swift │ │ ├── 05_anneal.swift │ │ ├── 05b_early_stopping.swift │ │ ├── 06_cuda.swift │ │ └── 07_batchnorm.swift ├── FastaiNotebook_08_data_block │ ├── Package.resolved │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_08_data_block │ │ ├── 00_load_data.swift │ │ ├── 01_matmul.swift │ │ ├── 01a_fastai_layers.swift │ │ ├── 02_fully_connected.swift │ │ ├── 02a_why_sqrt5.swift │ │ ├── 03_minibatch_training.swift │ │ ├── 04_callbacks.swift │ │ ├── 05_anneal.swift │ │ ├── 05b_early_stopping.swift │ │ ├── 06_cuda.swift │ │ ├── 07_batchnorm.swift │ │ └── 08_data_block.swift ├── FastaiNotebook_08a_heterogeneous_dictionary │ ├── Package.resolved │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_08a_heterogeneous_dictionary │ │ ├── 00_load_data.swift │ │ ├── 01_matmul.swift │ │ ├── 01a_fastai_layers.swift │ │ ├── 02_fully_connected.swift │ │ ├── 02a_why_sqrt5.swift │ │ ├── 03_minibatch_training.swift │ │ ├── 04_callbacks.swift │ │ ├── 05_anneal.swift │ │ ├── 05b_early_stopping.swift │ │ ├── 06_cuda.swift │ │ ├── 07_batchnorm.swift │ │ ├── 08_data_block.swift │ │ └── 08a_heterogeneous_dictionary.swift ├── FastaiNotebook_08c_data_block_generic │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_08c_data_block_generic │ │ ├── 00_load_data.swift │ │ ├── 01_matmul.swift │ │ ├── 01a_fastai_layers.swift │ │ ├── 02_fully_connected.swift │ │ ├── 02a_why_sqrt5.swift │ │ ├── 03_minibatch_training.swift │ │ ├── 04_callbacks.swift │ │ ├── 05_anneal.swift │ │ ├── 05b_early_stopping.swift │ │ ├── 06_cuda.swift │ │ ├── 07_batchnorm.swift │ │ └── 08c_data_block_generic.swift ├── FastaiNotebook_09_optimizer │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_09_optimizer │ │ ├── 00_load_data.swift │ │ ├── 01_matmul.swift │ │ ├── 01a_fastai_layers.swift │ │ ├── 02_fully_connected.swift │ │ ├── 02a_why_sqrt5.swift │ │ ├── 03_minibatch_training.swift │ │ ├── 04_callbacks.swift │ │ ├── 05_anneal.swift │ │ ├── 05b_early_stopping.swift │ │ ├── 06_cuda.swift │ │ ├── 07_batchnorm.swift │ │ ├── 08_data_block.swift │ │ ├── 08a_heterogeneous_dictionary.swift │ │ └── 09_optimizer.swift ├── FastaiNotebook_10_mixup_ls │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_10_mixup_ls │ │ ├── 00_load_data.swift │ │ ├── 01_matmul.swift │ │ ├── 01a_fastai_layers.swift │ │ ├── 02_fully_connected.swift │ │ ├── 02a_why_sqrt5.swift │ │ ├── 03_minibatch_training.swift │ │ ├── 04_callbacks.swift │ │ ├── 05_anneal.swift │ │ ├── 05b_early_stopping.swift │ │ ├── 06_cuda.swift │ │ ├── 07_batchnorm.swift │ │ ├── 08_data_block.swift │ │ ├── 08a_heterogeneous_dictionary.swift │ │ ├── 09_optimizer.swift │ │ └── 10_mixup_ls.swift ├── FastaiNotebook_11_imagenette │ ├── Package.swift │ └── Sources │ │ └── FastaiNotebook_11_imagenette │ │ ├── 00_load_data.swift │ │ ├── 01_matmul.swift │ │ ├── 01a_fastai_layers.swift │ │ ├── 02_fully_connected.swift │ │ ├── 02a_why_sqrt5.swift │ │ ├── 03_minibatch_training.swift │ │ ├── 04_callbacks.swift │ │ ├── 05_anneal.swift │ │ ├── 05b_early_stopping.swift │ │ ├── 06_cuda.swift │ │ ├── 07_batchnorm.swift │ │ ├── 08_data_block.swift │ │ ├── 08a_heterogeneous_dictionary.swift │ │ ├── 09_optimizer.swift │ │ ├── 10_mixup_ls.swift │ │ └── 11_imagenette.swift ├── Imagenette │ ├── .gitignore │ ├── Package.resolved │ ├── Package.swift │ ├── README.md │ └── Sources │ │ └── imagenette │ │ └── main.swift ├── MemoryUsage.ipynb ├── MinimalDsBug.ipynb ├── SwiftCV │ ├── .gitignore │ ├── Extra │ │ └── Tests.ipynb │ ├── Package.resolved │ ├── Package.swift │ ├── README.md │ ├── Sources │ │ ├── COpenCV │ │ │ ├── core.cpp │ │ │ ├── imgcodecs.cpp │ │ │ ├── imgproc.cpp │ │ │ ├── include │ │ │ │ ├── core.h │ │ │ │ ├── imgcodecs.h │ │ │ │ ├── imgproc.h │ │ │ │ └── version.h │ │ │ └── version.cpp │ │ ├── SwiftCV │ │ │ ├── ConcurrentMap.swift │ │ │ ├── Enums.swift │ │ │ ├── SwiftCV.swift │ │ │ └── TensorFlowConversion.swift │ │ ├── dataload │ │ │ └── main.swift │ │ └── opencv4 │ │ │ └── module.modulemap │ ├── Tests │ │ ├── LinuxMain.swift │ │ └── SwiftCVTests │ │ │ ├── SwiftCVTests.swift │ │ │ ├── TensorFlowConversionTests.swift │ │ │ ├── XCTestManifests.swift │ │ │ └── fixtures │ │ │ ├── blur.jpg │ │ │ ├── border.jpg │ │ │ ├── grey.jpg │ │ │ ├── resize.jpg │ │ │ ├── test.png │ │ │ └── zoom.jpg │ └── install │ │ ├── OpenCVFindOpenBLAS.cmake │ │ └── install_cv4.sh ├── SwiftSox │ ├── .gitignore │ ├── Package.swift │ ├── README.md │ ├── Sources │ │ ├── SwiftSox │ │ │ └── SwiftSox.swift │ │ └── sox │ │ │ ├── module.modulemap │ │ │ └── soxu.h │ ├── Tests │ │ ├── LinuxMain.swift │ │ └── SwiftSoxTests │ │ │ ├── SwiftSoxTests.swift │ │ │ └── XCTestManifests.swift │ ├── install.sh │ └── sounds │ │ ├── beep-01a.mp3 │ │ └── chris.mp3 ├── SwiftVips │ ├── .gitignore │ ├── Package.resolved │ ├── Package.swift │ ├── README.md │ ├── Sources │ │ ├── CSwiftVips │ │ │ ├── core.c │ │ │ └── include │ │ │ │ └── core.h │ │ ├── SwiftVips │ │ │ ├── ConcurrentMap.swift │ │ │ └── SwiftVips.swift │ │ ├── dataload │ │ │ └── main.swift │ │ └── vips │ │ │ ├── module.modulemap │ │ │ └── shim.h │ └── install.sh ├── audio.ipynb ├── c_interop_examples.ipynb ├── datablock │ ├── .gitignore │ ├── Package.resolved │ ├── Package.swift │ ├── README.md │ └── Sources │ │ └── datablock │ │ └── main.swift ├── grid_sample.ipynb ├── minimal ├── minimal.swift └── opencv_integration_example.ipynb └── tools ├── fastai-nbstripout ├── read-nbs ├── run-after-git-clone ├── take-snapshot ├── trust-doc-nbs ├── trust-doc-nbs-install-hook └── trust-origin-git-config /.gitattributes: -------------------------------------------------------------------------------- 1 | *.ipynb filter=fastai-nbstripout-docs 2 | 3 | *.ipynb diff=ipynb-docs 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: strip git-clean-nb_dirs-check 2 | 3 | nb_dirs = dev_nb dev_course dev_swift 4 | 5 | git-clean-nb_dirs-check: 6 | @echo "\n\n*** Checking that everything under '$(nb_dirs)' is committed" 7 | @if [ -n "$(shell git status -s $(nb_dirs))" ]; then\ 8 | echo "git status $(nb_dirs) is not clean. You have uncommitted git files (use git stash or git commit)";\ 9 | exit 1;\ 10 | else\ 11 | echo "git status $(nb_dirs) is clean";\ 12 | fi 13 | 14 | strip: # strip out nbs, that were committed unstripped out, and commit+push 15 | ${MAKE} strip-try; \ 16 | ${MAKE} strip-finally 17 | 18 | strip-finally: # restore .gitconfig 19 | tools/trust-origin-git-config -e 20 | 21 | strip-try: git-clean-nb_dirs-check # try to strip out && commit 22 | @echo "Stripping out nbs" 23 | tools/trust-origin-git-config -d 24 | git pull 25 | tools/fastai-nbstripout dev_nb/*ipynb dev_nb/experiments/*ipynb 26 | tools/fastai-nbstripout -d dev_course/*/*ipynb dev_swift/*ipynb 27 | git commit -m "strip out nbs" $(nb_dirs) 28 | git push 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # fastai_dev 2 | 3 | This repo is used for fastai development. If you're looking for the version 2 of the fastai library, go [here](https://github.com/fastai/fastai2). -------------------------------------------------------------------------------- /data/.gitignore: -------------------------------------------------------------------------------- 1 | */ 2 | faces.zip 3 | -------------------------------------------------------------------------------- /data/adult_sample.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/data/adult_sample.tgz -------------------------------------------------------------------------------- /data/imdb_sample.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/data/imdb_sample.tgz -------------------------------------------------------------------------------- /data/mnist_sample.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/data/mnist_sample.tgz -------------------------------------------------------------------------------- /data/movie_lens_sample.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/data/movie_lens_sample.tgz -------------------------------------------------------------------------------- /dev/.gitignore: -------------------------------------------------------------------------------- 1 | data/ 2 | docs/ 3 | -------------------------------------------------------------------------------- /dev/.root: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/dev/.root -------------------------------------------------------------------------------- /dev/95_index.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Welcome to fastai v2\n", 8 | "> NB: This is still in early development. Use v1 unless you want to contribute to the next version of fastai" 9 | ] 10 | }, 11 | { 12 | "cell_type": "markdown", 13 | "metadata": {}, 14 | "source": [ 15 | "- TODO: write this page!" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [] 24 | } 25 | ], 26 | "metadata": { 27 | "jekyll": { 28 | "keywords": "fastai", 29 | "toc": "false" 30 | }, 31 | "kernelspec": { 32 | "display_name": "Python 3", 33 | "language": "python", 34 | "name": "python3" 35 | } 36 | }, 37 | "nbformat": 4, 38 | "nbformat_minor": 2 39 | } 40 | -------------------------------------------------------------------------------- /dev/config.yml: -------------------------------------------------------------------------------- 1 | doc_path: ../docs 2 | git_url: https://github.com/fastai/fastai_dev/tree/master/dev 3 | lib_name: fastai2 4 | lib_path: fastai2 5 | nbs_path: . 6 | tst_flags: 7 | - cuda 8 | - slow 9 | - cpp 10 | -------------------------------------------------------------------------------- /dev/fastai2/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/dev/fastai2/__init__.py -------------------------------------------------------------------------------- /dev/fastai2/basics.py: -------------------------------------------------------------------------------- 1 | from .data.all import * 2 | from .optimizer import * 3 | from .learner import * 4 | from .metrics import * 5 | from .interpret import * -------------------------------------------------------------------------------- /dev/fastai2/callback/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dev/fastai2/callback/all.py: -------------------------------------------------------------------------------- 1 | from .data import * 2 | from .fp16 import * 3 | from .hook import * 4 | from .mixup import * 5 | from .progress import * 6 | from .schedule import * 7 | from .tracker import * 8 | -------------------------------------------------------------------------------- /dev/fastai2/callback/data.py: -------------------------------------------------------------------------------- 1 | #AUTOGENERATED! DO NOT EDIT! File to edit: dev/14a_callback_data.ipynb (unless otherwise specified). 2 | 3 | __all__ = ['CollectDataCallback', 'WeightedDL', 'weighted_databunch'] 4 | 5 | #Cell 6 | from ..test import * 7 | from ..basics import * 8 | 9 | #Cell 10 | class CollectDataCallback(Callback): 11 | "Collect all batches, along with `pred` and `loss`, into `self.data`. Mainly for testing" 12 | def begin_fit(self): self.data = L() 13 | def after_batch(self): self.data.append(to_detach((self.xb,self.yb,self.pred,self.loss))) 14 | 15 | #Cell 16 | @delegates() 17 | class WeightedDL(TfmdDL): 18 | def __init__(self, dataset=None, bs=None, wgts=None, **kwargs): 19 | super().__init__(dataset=dataset, bs=bs, **kwargs) 20 | wgts = array([1.]*len(dataset) if wgts is None else wgts) 21 | self.wgts = wgts/wgts.sum() 22 | 23 | def get_idxs(self): 24 | if self.n==0: return [] 25 | if not self.shuffle: return super().get_idxs() 26 | return list(np.random.choice(self.n, self.n, p=self.wgts)) 27 | 28 | #Cell 29 | @patch 30 | @delegates(DataSource.databunch) 31 | def weighted_databunch(self:DataSource, wgts, bs=16, **kwargs): 32 | xtra_kwargs = [{}] * (self.n_subsets-1) 33 | return self.databunch(bs=bs, dl_type=WeightedDL, dl_kwargs=({'wgts':wgts}, *xtra_kwargs), **kwargs) -------------------------------------------------------------------------------- /dev/fastai2/callback/rnn.py: -------------------------------------------------------------------------------- 1 | #AUTOGENERATED! DO NOT EDIT! File to edit: dev/34_callback_rnn.ipynb (unless otherwise specified). 2 | 3 | __all__ = ['RNNTrainer'] 4 | 5 | #Cell 6 | from ..test import * 7 | from ..data.all import * 8 | from ..optimizer import * 9 | from ..learner import * 10 | 11 | #Cell 12 | @docs 13 | class RNNTrainer(Callback): 14 | "`Callback` that adds AR and TAR regularization in RNN training" 15 | def __init__(self, alpha=0., beta=0.): self.alpha,self.beta = alpha,beta 16 | 17 | def begin_train(self): self.model.reset() 18 | def begin_validate(self): self.model.reset() 19 | def after_pred(self): 20 | self.raw_out,self.out = self.pred[1],self.pred[2] 21 | self.learn.pred = self.pred[0] 22 | 23 | def after_loss(self): 24 | if not self.training: return 25 | if self.alpha != 0.: self.learn.loss += self.alpha * self.out[-1].float().pow(2).mean() 26 | if self.beta != 0.: 27 | h = self.raw_out[-1] 28 | if len(h)>1: self.learn.loss += self.beta * (h[:,1:] - h[:,:-1]).float().pow(2).mean() 29 | 30 | _docs = dict(begin_train="Reset the model before training", 31 | begin_validate="Reset the model before validation", 32 | after_pred="Save the raw and dropped-out outputs and only keep the true output for loss computation", 33 | after_loss="Add AR and TAR regularization") -------------------------------------------------------------------------------- /dev/fastai2/core/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/dev/fastai2/core/__init__.py -------------------------------------------------------------------------------- /dev/fastai2/core/all.py: -------------------------------------------------------------------------------- 1 | from .imports import * 2 | from .foundation import * 3 | from .dispatch import * 4 | from .utils import * 5 | from .script import * 6 | from .transform import * 7 | -------------------------------------------------------------------------------- /dev/fastai2/core/script.py: -------------------------------------------------------------------------------- 1 | #AUTOGENERATED! DO NOT EDIT! File to edit: dev/02_core_script.ipynb (unless otherwise specified). 2 | 3 | __all__ = ['Param', 'anno_parser', 'call_parse'] 4 | 5 | #Cell 6 | from .foundation import * 7 | from .utils import * 8 | from .imports import * 9 | from ..test import * 10 | 11 | from argparse import ArgumentParser 12 | 13 | #Cell 14 | def _param_pre(self): return '--' if self.opt else '' 15 | def _param_kwargs(self): return {k:v for k,v in self.__dict__.items() if v is not None and k!='opt'} 16 | 17 | #Cell 18 | mk_class('Param', help=None, type=None, opt=True, action=None, nargs=None, const=None, choices=None, required=None, 19 | pre=property(_param_pre), kwargs=property(_param_kwargs), 20 | doc="A parameter in a function used in `anno_parser` or `call_parse`") 21 | 22 | #Cell 23 | def anno_parser(func): 24 | "Look at params (annotated with `Param`) in func and return an `ArgumentParser`" 25 | p = ArgumentParser(description=func.__doc__) 26 | for k,v in inspect.signature(func).parameters.items(): 27 | param = func.__annotations__.get(k, Param()) 28 | kwargs = param.kwargs 29 | if v.default != inspect.Parameter.empty: kwargs['default'] = v.default 30 | p.add_argument(f"{param.pre}{k}", **kwargs) 31 | return p 32 | 33 | #Cell 34 | def call_parse(func): 35 | "Decorator to create a simple CLI from `func` using `anno_parser`" 36 | name = inspect.currentframe().f_back.f_globals['__name__'] 37 | if name == "__main__": 38 | args = anno_parser(func).parse_args() 39 | func(**args.__dict__) 40 | else: return func -------------------------------------------------------------------------------- /dev/fastai2/launch.py: -------------------------------------------------------------------------------- 1 | import subprocess, torch 2 | from fastai2.basics import * 3 | 4 | @call_parse 5 | def main( 6 | gpus:Param("The GPUs to use for distributed training", str)='all', 7 | script:Param("Script to run", str, opt=False)='', 8 | args:Param("Args to pass to script", nargs='...', opt=False)='' 9 | ): 10 | "PyTorch distributed training launch helper that spawns multiple distributed processes" 11 | # Loosely based on torch.distributed.launch 12 | current_env = os.environ.copy() 13 | gpus = list(range(torch.cuda.device_count())) if gpus=='all' else list(gpus) 14 | current_env["WORLD_SIZE"] = str(len(gpus)) 15 | current_env["MASTER_ADDR"] = '127.0.0.1' 16 | current_env["MASTER_PORT"] = '29500' 17 | 18 | processes = [] 19 | for i,gpu in enumerate(gpus): 20 | current_env["RANK"] = str(i) 21 | cmd = [sys.executable, "-u", script, f"--gpu={gpu}"] + args 22 | process = subprocess.Popen(cmd, env=current_env) 23 | processes.append(process) 24 | 25 | for process in processes: process.wait() 26 | -------------------------------------------------------------------------------- /dev/fastai2/medical/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/dev/fastai2/medical/__init__.py -------------------------------------------------------------------------------- /dev/fastai2/medical/text.py: -------------------------------------------------------------------------------- 1 | #AUTOGENERATED! DO NOT EDIT! File to edit: dev/65_medical_text.ipynb (unless otherwise specified). 2 | 3 | __all__ = [] 4 | 5 | #Cell 6 | from ..test import * 7 | from ..core import * 8 | from ..data.all import * 9 | from ..optimizer import * 10 | from ..learner import * 11 | from ..metrics import * -------------------------------------------------------------------------------- /dev/fastai2/notebook/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/dev/fastai2/notebook/__init__.py -------------------------------------------------------------------------------- /dev/fastai2/notebook/autogen.tpl: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /dev/fastai2/notebook/core.py: -------------------------------------------------------------------------------- 1 | #AUTOGENERATED! DO NOT EDIT! File to edit: dev/90_notebook_core.ipynb (unless otherwise specified). 2 | 3 | __all__ = ['in_ipython', 'IN_IPYTHON', 'in_colab', 'IN_COLAB', 'in_notebook', 'IN_NOTEBOOK', 'DocsTestClass'] 4 | 5 | #Cell 6 | from ..core.imports import * 7 | 8 | #Cell 9 | def in_ipython(): 10 | "Check if the code is running in the ipython environment (jupyter including)" 11 | program_name = os.path.basename(os.getenv('_', '')) 12 | if ('jupyter-notebook' in program_name or # jupyter-notebook 13 | 'ipython' in program_name or # ipython 14 | 'JPY_PARENT_PID' in os.environ): # ipython-notebook 15 | return True 16 | else: 17 | return False 18 | 19 | IN_IPYTHON = in_ipython() 20 | 21 | #Cell 22 | def in_colab(): 23 | "Check if the code is running in Google Colaboratory" 24 | try: 25 | from google import colab 26 | return True 27 | except: return False 28 | 29 | IN_COLAB = in_colab() 30 | 31 | #Cell 32 | def in_notebook(): 33 | "Check if the code is running in a jupyter notebook" 34 | if in_colab(): return True 35 | try: 36 | shell = get_ipython().__class__.__name__ 37 | if shell == 'ZMQInteractiveShell': return True # Jupyter notebook, Spyder or qtconsole 38 | elif shell == 'TerminalInteractiveShell': return False # Terminal running IPython 39 | else: return False # Other type (?) 40 | except NameError: return False # Probably standard Python interpreter 41 | 42 | IN_NOTEBOOK = in_notebook() 43 | 44 | #Cell 45 | class DocsTestClass: 46 | def test(): pass -------------------------------------------------------------------------------- /dev/fastai2/notebook/hide.tpl: -------------------------------------------------------------------------------- 1 | {%- extends 'basic.tpl' -%} 2 | 3 | {% block input_group -%} 4 | {%- if cell.metadata.hide_input or nb.metadata.hide_input -%} 5 | {%- else -%} 6 | {{ super() }} 7 | {%- endif -%} 8 | {% endblock input_group %} 9 | 10 | {% block output_group -%} 11 | {%- if cell.metadata.hide_output -%} 12 | {%- else -%} 13 | {{ super() }} 14 | {%- endif -%} 15 | {% endblock output_group %} 16 | 17 | {% block output_area_prompt %} 18 | {%- if cell.metadata.hide_input or nb.metadata.hide_input -%} 19 |
20 | {%- else -%} 21 | {{ super() }} 22 | {%- endif -%} 23 | {% endblock output_area_prompt %} 24 | -------------------------------------------------------------------------------- /dev/fastai2/notebook/index_pytorch.txt: -------------------------------------------------------------------------------- 1 | { 2 | "Tensor": "https://pytorch.org/docs/stable/tensors.html#torch-tensor", 3 | "device": "https://pytorch.org/docs/stable/tensor_attributes.html#torch-device", 4 | "DataLoader": "https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader" 5 | } -------------------------------------------------------------------------------- /dev/fastai2/notebook/jekyll-md.tpl: -------------------------------------------------------------------------------- 1 | {%- extends 'markdown.tpl' -%}{% block body %}--- 2 | {% if resources.title != "" and resources.title != nil %}title: {{resources.title}}{% endif %} 3 | {% if resources.author != "" and resources.author != nil %}author: {{resources.author}}{% endif %} 4 | {% if resources.date != "" and resources.date != nil %}date: {{resources.date}}{% endif %} 5 | {% if resources.tags != "" and resources.tags != nil %}tags: {{resources.tags}}{% endif %} 6 | {% if resources.summary != "" and resources.summary != nil %}summary: "{{resources.summary}}"{% endif %} 7 | --- 8 | 9 | {{ super() }} 10 | {%- endblock body %} 11 | 12 | {% block codecell -%} 13 |
14 | {{ super() }} 15 |
16 | {% endblock codecell %} 17 | 18 | {% block input_group -%} 19 |
20 | {{ super() }} 21 |
22 | {% endblock input_group %} 23 | 24 | {% block output_group -%} 25 |
26 | {{ super() }} 27 |
28 | {% endblock output_group %} 29 | 30 | -------------------------------------------------------------------------------- /dev/fastai2/notebook/jekyll.tpl: -------------------------------------------------------------------------------- 1 | {%- extends 'hide.tpl' -%}{% block body %}--- 2 | {% if resources.toc != "" and resources.toc != nil %}toc: {{resources.toc}}{% endif %} 3 | {% if resources.title != "" and resources.title != nil %}title: {{resources.title}}{% endif %} 4 | keywords: {{resources.keywords}} 5 | sidebar: home_sidebar 6 | {% if resources.tags != "" and resources.tags != nil %}tags: {{resources.tags}}{% endif %} 7 | {% if resources.summary != "" and resources.summary != nil %}summary: "{{resources.summary}}"{% endif %} 8 | --- 9 | {% include 'autogen.tpl' %} 10 | 11 |
12 | {{ super() }} 13 |
14 | {%- endblock body %} 15 | -------------------------------------------------------------------------------- /dev/fastai2/tabular/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/dev/fastai2/tabular/__init__.py -------------------------------------------------------------------------------- /dev/fastai2/test_utils.py: -------------------------------------------------------------------------------- 1 | #AUTOGENERATED! DO NOT EDIT! File to edit: dev/97_utils_test.ipynb (unless otherwise specified). 2 | 3 | __all__ = ['synth_dbunch', 'RegModel', 'synth_learner'] 4 | 5 | #Cell 6 | from .test import * 7 | from .data.all import * 8 | from .optimizer import * 9 | from .learner import * 10 | from torch.utils.data import TensorDataset 11 | 12 | #Cell 13 | from torch.utils.data import TensorDataset 14 | 15 | def synth_dbunch(a=2, b=3, bs=16, n_train=10, n_valid=2, cuda=False): 16 | def get_data(n): 17 | x = torch.randn(bs*n, 1) 18 | return TensorDataset(x, a*x + b + 0.1*torch.randn(bs*n, 1)) 19 | train_ds = get_data(n_train) 20 | valid_ds = get_data(n_valid) 21 | tfms = Cuda() if cuda else None 22 | train_dl = TfmdDL(train_ds, bs=bs, shuffle=True, after_batch=tfms, num_workers=0) 23 | valid_dl = TfmdDL(valid_ds, bs=bs, after_batch=tfms, num_workers=0) 24 | return DataBunch(train_dl, valid_dl) 25 | 26 | #Cell 27 | class RegModel(Module): 28 | def __init__(self): self.a,self.b = nn.Parameter(torch.randn(1)),nn.Parameter(torch.randn(1)) 29 | def forward(self, x): return x*self.a + self.b 30 | 31 | #Cell 32 | @delegates(Learner.__init__) 33 | def synth_learner(n_trn=10, n_val=2, cuda=False, lr=1e-3, data=None, **kwargs): 34 | if data is None: data = synth_dbunch(n_train=n_trn,n_valid=n_val, cuda=cuda) 35 | return Learner(data, RegModel(), lr=lr, loss_func=MSELossFlat(), 36 | opt_func=partial(SGD, mom=0.9), **kwargs) -------------------------------------------------------------------------------- /dev/fastai2/text/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dev/fastai2/text/all.py: -------------------------------------------------------------------------------- 1 | from .core import * 2 | from .data import * 3 | from .models import * 4 | from .learner import * 5 | -------------------------------------------------------------------------------- /dev/fastai2/text/models/__init__.py: -------------------------------------------------------------------------------- 1 | from .core import * 2 | from .awdlstm import * -------------------------------------------------------------------------------- /dev/fastai2/text/models/bwd_forget_mult_cuda.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | // CUDA forward declarations 6 | at::Tensor bwd_forget_mult_cuda_forward(at::Tensor x, at::Tensor f, at::Tensor output, bool batch_first); 7 | 8 | // C++ interface 9 | 10 | #define CHECK_CUDA(x) AT_ASSERTM(x.type().is_cuda(), #x " must be a CUDA tensor") 11 | #define CHECK_CONTIGUOUS(x) AT_ASSERTM(x.is_contiguous(), #x " must be contiguous") 12 | #define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x) 13 | 14 | at::Tensor bwd_forget_mult_forward(at::Tensor x, at::Tensor f, at::Tensor output, bool batch_first) { 15 | CHECK_INPUT(x); CHECK_INPUT(f); CHECK_INPUT(output); 16 | return bwd_forget_mult_cuda_forward(x, f, output, batch_first); 17 | } 18 | 19 | std::vector bwd_forget_mult_cuda_backward(at::Tensor x, at::Tensor f, at::Tensor output, 20 | at::Tensor grad_output, bool batch_first); 21 | 22 | std::vector bwd_forget_mult_backward(at::Tensor x, at::Tensor f, at::Tensor output, 23 | at::Tensor grad_output, bool batch_first) { 24 | CHECK_INPUT(x); CHECK_INPUT(f); CHECK_INPUT(output); 25 | return bwd_forget_mult_cuda_backward(x, f, output, grad_output, batch_first); 26 | } 27 | 28 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 29 | m.def("forward", &bwd_forget_mult_forward, "BwdForgetMult forward (CUDA)"); 30 | m.def("backward", &bwd_forget_mult_backward, "BwdForgetMult backward (CUDA)"); 31 | } 32 | -------------------------------------------------------------------------------- /dev/fastai2/text/models/forget_mult_cuda.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | // CUDA forward declarations 6 | at::Tensor forget_mult_cuda_forward(at::Tensor x, at::Tensor f, at::Tensor output, bool batch_first); 7 | 8 | // C++ interface 9 | 10 | #define CHECK_CUDA(x) AT_ASSERTM(x.type().is_cuda(), #x " must be a CUDA tensor") 11 | #define CHECK_CONTIGUOUS(x) AT_ASSERTM(x.is_contiguous(), #x " must be contiguous") 12 | #define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x) 13 | 14 | at::Tensor forget_mult_forward(at::Tensor x, at::Tensor f, at::Tensor output, bool batch_first) { 15 | CHECK_INPUT(x); CHECK_INPUT(f); CHECK_INPUT(output); 16 | return forget_mult_cuda_forward(x, f, output, batch_first); 17 | } 18 | 19 | std::vector forget_mult_cuda_backward(at::Tensor x, at::Tensor f, at::Tensor output, 20 | at::Tensor grad_output, bool batch_first); 21 | 22 | std::vector forget_mult_backward(at::Tensor x, at::Tensor f, at::Tensor output, 23 | at::Tensor grad_output, bool batch_first) { 24 | CHECK_INPUT(x); CHECK_INPUT(f); CHECK_INPUT(output); 25 | return forget_mult_cuda_backward(x, f, output, grad_output, batch_first); 26 | } 27 | 28 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 29 | m.def("forward", &forget_mult_forward, "ForgetMult forward (CUDA)"); 30 | m.def("backward", &forget_mult_backward, "ForgetMult backward (CUDA)"); 31 | } 32 | -------------------------------------------------------------------------------- /dev/fastai2/torch_basics.py: -------------------------------------------------------------------------------- 1 | from torch import multiprocessing 2 | from .core.all import * 3 | from .torch_imports import * 4 | from .torch_core import * 5 | from .layers import * 6 | -------------------------------------------------------------------------------- /dev/fastai2/torch_imports.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch import as_tensor,Tensor,ByteTensor,LongTensor,FloatTensor,HalfTensor,DoubleTensor 3 | import torch.nn as nn 4 | import torch.nn.functional as F 5 | from torch.utils.data import SequentialSampler,RandomSampler,Sampler,BatchSampler 6 | from torch.utils.data import DataLoader,IterableDataset,get_worker_info 7 | from torch.utils.data._utils.collate import default_collate,default_convert 8 | 9 | -------------------------------------------------------------------------------- /dev/fastai2/version.py: -------------------------------------------------------------------------------- 1 | __all__ = ['__version__'] 2 | __version__ = '2.0.1' 3 | -------------------------------------------------------------------------------- /dev/fastai2/vision/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /dev/fastai2/vision/all.py: -------------------------------------------------------------------------------- 1 | from ..data.core import * 2 | from .augment import * 3 | from .core import * 4 | from .data import * 5 | from .models.all import * 6 | from .learner import * 7 | from .models import * 8 | from .utils import * 9 | -------------------------------------------------------------------------------- /dev/fastai2/vision/models/__init__.py: -------------------------------------------------------------------------------- 1 | from . import xresnet 2 | from . import unet 3 | from torchvision.models import ResNet,resnet18,resnet34,resnet50,resnet101,resnet152 4 | from torchvision.models import SqueezeNet,squeezenet1_0,squeezenet1_1 5 | from torchvision.models import densenet121,densenet169,densenet201,densenet161 6 | from torchvision.models import vgg11_bn,vgg13_bn,vgg16_bn,vgg19_bn,alexnet -------------------------------------------------------------------------------- /dev/fastai2/vision/models/all.py: -------------------------------------------------------------------------------- 1 | from .xresnet import * 2 | from .unet import * -------------------------------------------------------------------------------- /dev/files/.gitignore: -------------------------------------------------------------------------------- 1 | test.txt 2 | -------------------------------------------------------------------------------- /dev/files/test.txt.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/dev/files/test.txt.bz2 -------------------------------------------------------------------------------- /dev/images/Mixed_precision.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/dev/images/Mixed_precision.jpeg -------------------------------------------------------------------------------- /dev/images/half.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/dev/images/half.png -------------------------------------------------------------------------------- /dev/images/half_representation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/dev/images/half_representation.png -------------------------------------------------------------------------------- /dev/images/mnist3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/dev/images/mnist3.png -------------------------------------------------------------------------------- /dev/images/pixelshuffle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/dev/images/pixelshuffle.png -------------------------------------------------------------------------------- /dev/images/puppy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/dev/images/puppy.jpg -------------------------------------------------------------------------------- /dev/images/sample.dcm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fastai/fastai_dev/4a33cb2e5f4d480e47f1f16875b8f10d8c205a8c/dev/images/sample.dcm -------------------------------------------------------------------------------- /dev/posts/.gitignore: -------------------------------------------------------------------------------- 1 | *.md 2 | -------------------------------------------------------------------------------- /dev/tools/diff_nb_script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from nbdev.export import diff_nb_script 3 | 4 | diff_nb_script() 5 | -------------------------------------------------------------------------------- /dev/tools/fastai2: -------------------------------------------------------------------------------- 1 | ../fastai2/ -------------------------------------------------------------------------------- /dev/tools/notebook2script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from nbdev.export import notebook2script 3 | from fastai2.core.script import * 4 | 5 | @call_parse 6 | def main(fname:Param("A notebook name or glob to convert", str)=None): 7 | notebook2script(fname=fname) 8 | -------------------------------------------------------------------------------- /dev/tools/script2notebook: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | from nbdev.export import script2notebook 3 | from fastai2.core.script import * 4 | 5 | @call_parse 6 | def main(fname:Param("A filename or glob to convert", str)=None): 7 | script2notebook(fname=fname) 8 | -------------------------------------------------------------------------------- /dev/tools/test_nbs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import time,random,glob,os 3 | from pathlib import Path 4 | from fastai2.core.script import * 5 | from fastai2.torch_core import parallel 6 | from nbdev.test import test_nb 7 | from nbdev.core import Config 8 | 9 | def get_fns(path,max_num,fn): 10 | path = Path(path) 11 | if fn: return path.glob(fn) 12 | fns = list(path.glob("*.ipynb")) 13 | return [f for f in fns if f.name List[Any]: return list(OrderedDict.fromkeys(x).keys()) 14 | 15 | def fbeta(y_pred:Tensor, y_true:Tensor, thresh:float=0.5, beta:float=2, eps:float=1e-9, sigmoid:bool=True) -> Rank0Tensor: 16 | "Computes the f_beta between preds and targets" 17 | beta2 = beta**2 18 | if sigmoid: y_pred = y_pred.sigmoid() 19 | y_pred = (y_pred>thresh).float() 20 | y_true = y_true.float() 21 | TP = (y_pred*y_true).sum(dim=1) 22 | prec = TP/(y_pred.sum(dim=1)+eps) 23 | rec = TP/(y_true.sum(dim=1)+eps) 24 | res = (prec*rec)/(prec*beta2+rec+eps)*(1+beta2) 25 | return res.mean() 26 | 27 | def accuracy_thresh(y_pred:Tensor, y_true:Tensor, thresh:float=0.5, sigmoid:bool=True) -> Rank0Tensor: 28 | if sigmoid: y_pred = y_pred.sigmoid() 29 | return ((y_pred>thresh)==y_true.byte()).float().mean() -------------------------------------------------------------------------------- /dev_nb/nb_104a.py: -------------------------------------------------------------------------------- 1 | 2 | ################################################# 3 | ### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ### 4 | ################################################# 5 | # file to edit: dev_nb/104a_camvid.ipynb 6 | 7 | from nb_104 import * 8 | 9 | @classmethod 10 | def Learner_create_unet(cls, data:DataBunch, arch:Callable, pretrained:bool=True, 11 | split_on:Optional[SplitFuncOrIdxList]=None, **kwargs:Any)->None: 12 | "Build Unet learners." 13 | meta = cnn_config(arch) 14 | body = create_body(arch(pretrained), meta['cut']) 15 | model = models.unet.DynamicUnet(body, n_classes=data.c).cuda() 16 | learn = cls(data, model, **kwargs) 17 | learn.split(ifnone(split_on,meta['split'])) 18 | if pretrained: learn.freeze() 19 | apply_init(model[2], nn.init.kaiming_normal_) 20 | return learn 21 | 22 | Learner.create_unet = Learner_create_unet -------------------------------------------------------------------------------- /dev_nb/nb_104b.py: -------------------------------------------------------------------------------- 1 | 2 | ################################################# 3 | ### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ### 4 | ################################################# 5 | # file to edit: dev_nb/104b_pets_planets.ipynb 6 | 7 | from nb_104a import * -------------------------------------------------------------------------------- /dev_nb/notebook2script.py: -------------------------------------------------------------------------------- 1 | 2 | # use tools/sync-nb-exports to autogenerate all relevant files automatically 3 | 4 | import json, fire, re, os.path 5 | from pathlib import Path 6 | 7 | def is_export(cell): 8 | if cell['cell_type'] != 'code': return False 9 | src = cell['source'] 10 | if len(src) == 0 or len(src[0]) < 7: return False 11 | #import pdb; pdb.set_trace() 12 | return re.match(r'^\s*#\s*export\s*$', src[0], re.IGNORECASE) is not None 13 | 14 | def get_py_fname(fname): 15 | fname = os.path.splitext(fname)[0] 16 | number = fname.split('_')[0] 17 | return f'nb_{number}.py' 18 | 19 | def notebook2script(fname): 20 | fname = Path(fname) 21 | fname_out = get_py_fname(fname.name) 22 | main_dic = json.load(open(fname,'r')) 23 | cells = main_dic['cells'] 24 | code_cells = [c for c in cells if is_export(c)] 25 | module = f''' 26 | ################################################# 27 | ### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ### 28 | ################################################# 29 | # file to edit: dev_nb/{fname.name}\n\n''' 30 | for cell in code_cells: module += ''.join(cell['source'][1:]) + '\n\n' 31 | # remove trailing spaces 32 | module = re.sub(r' +$', '', module, flags=re.MULTILINE) 33 | with open(fname_out,'w') as f: f.write(module[:-2]) 34 | print(f"Converted {fname} to {fname_out}") 35 | 36 | if __name__ == '__main__': fire.Fire(notebook2script) 37 | -------------------------------------------------------------------------------- /dev_nb/snapshot/.gitattributes: -------------------------------------------------------------------------------- 1 | *.ipynb filter=fastai-nbstripout-docs 2 | 3 | *.ipynb diff=ipynb-docs 4 | -------------------------------------------------------------------------------- /dev_nb/snapshot/README.md: -------------------------------------------------------------------------------- 1 | # Demo notebooks 2 | Notebooks in this directory do not have their outputs stripped automatically, so you can see the outputs of the notebooks execution. 3 | 4 | Chances are that the notebooks here are not up to date. 5 | 6 | For the latest version always check the corresponding original `dev_nb/00*.ipynb` notebooks. 7 | 8 | Also please do not attempt to modify or submit PRs for this version of the notebooks - always use the original instead. 9 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | .*/ 2 | _site/ 3 | vendor/ 4 | -------------------------------------------------------------------------------- /docs/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem 'github-pages', group: :jekyll_plugins 4 | -------------------------------------------------------------------------------- /docs/_data/alerts.yml: -------------------------------------------------------------------------------- 1 | tip: '