<jupyter_start><jupyter_text><jupyter_code>!curl -s https://course.fast.ai/setup/colab | bash
!pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html > /dev/null

!pip install torch torchvision --upgrade > /dev/null


!pip install fastai2 --upgrade > /dev/null
!pip freeze | grep fastai2
!pip freeze | grep torch
!nvidia-smi
# import warnings
# warnings.filterwarnings('ignore')
from fastai2.vision.all import *
path = untar_data(URLs.MNIST)
Path.BASE_PATH = path
path.ls()
datablock = DataBlock(
    blocks=(ImageBlock,CategoryBlock),
    get_items=get_image_files,
    get_y=parent_label,
    splitter=GrandparentSplitter(train_name='training',valid_name='testing'),
    item_tfms=Resize(50),
    batch_tfms=[*aug_transforms(do_flip=False,size=28,min_scale=0.9, max_warp=0.2, max_rotate=5,max_zoom=1.2), Normalize]
)
datablock.summary(path)
default_device()
bs = 256
dls = datablock.dataloaders(path, bs=bs)
dls.show_batch(max_n=15)
learner = cnn_learner(dls, resnet34, metrics=[accuracy, error_rate])
learner.fine_tune(4, freeze_epochs=4)
learner.save('stage-1')
default_device()
warnings.resetwarnings()
pos = 0.6
pcts = [0.2,0.3,0.5]
assert sum(pcts) == 1.
pcts = tensor([0] + L(pcts));pcts
assert torch.all(pcts >= 0)
pcts = torch.cumsum(pcts, 0);pcts
w = (pos >= pcts);w
u = w.nonzero()
u2 = w.nonzero()
idx = (pos >= pcts).nonzero().max(); idx
cos_sched = combined_cos(0.3, 0.25,0.5, 0.9)
res = cos_sched(0.4);res
learner.lr_find()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16272965879265092, 'fraction_numerical': 0.03937007874015748, 'mean_word_length': 5.747787610619469, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '146473', 'license': 'MIT', 'n_tokens_mistral': 668, 'n_tokens_neox': 635, 'n_words': 105, 'path': 'show_warning_test_latest_fastai2.ipynb', 'repo_name': 'edward-h-81/fastai-butch-landingin', 'size': '1524'}