Skip to content

Instantly share code, notes, and snippets.

View butchland's full-sized avatar

Butch Landingin butchland

View GitHub Profile

Keybase proof

I hereby claim:

  • I am butchland on github.
  • I am butchland (https://keybase.io/butchland) on keybase.
  • I have a public key ASBvBzjyR_hRPyRKgjiRO07GVwQ8Lr2kNAq3m_fvVBM_lgo

To claim this, I am signing this object:

@butchland
butchland / keybase.md
Created September 18, 2019 07:08
Keybase proof

Keybase proof

I hereby claim:

  • I am butchland on github.
  • I am butchland (https://keybase.io/butchland) on keybase.
  • I have a public key ASDCeJ1Bq2BMIUiRi_Yb2fh50ByveTx-O8TX1HDnTM-gTAo

To claim this, I am signing this object:

@butchland
butchland / 00_core.ipynb
Created August 10, 2020 08:39
Sample nbdev notebook which trigger `nbdev_build_docs` error
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@butchland
butchland / single_profile_forward.py
Created August 13, 2020 16:27
Program executed to generate single_profile_forward.tar.gz
# Run the model 1 pass forward (with grad enabled)
import fastai_xla_extensions.core
from fastai2.text.all import *
import torch_xla.debug.metrics as met
import torch_xla.core.xla_model as xm
# from my_timesaver_utils.profiling_callback import *
path = untar_data(URLs.IMDB_SAMPLE)
df = pd.read_csv(path/'texts.csv')
dls = TextDataLoaders.from_df(df,path=path, text_col='text', label_col='label',
@butchland
butchland / single_profile.py
Created August 13, 2020 17:03
Program executed to generate single_profile.tar.gz
import fastai_xla_extensions.core
from fastai2.text.all import *
import torch_xla.debug.metrics as met
# from my_timesaver_utils.profiling_callback import *
path = untar_data(URLs.IMDB_SAMPLE)
df = pd.read_csv(path/'texts.csv')
dls = TextDataLoaders.from_df(df,path=path, text_col='text', label_col='label', valid_col='is_valid')
learner = text_classifier_learner(dls, AWD_LSTM, drop_mult=0.5, metrics=accuracy)
#!/bin/bash
# simplifying this script as per Jeremy Howard's post
# here https://forums.fast.ai/t/major-new-changes-and-features/40742/18
LC_ALL=C find . -type f -name '*.ipynb' -exec sed -i '' s/begin_fit/before_fit/g {} +
LC_ALL=C find . -type f -name '*.ipynb' -exec sed -i '' s/begin_epoch/before_epoch/g {} +
LC_ALL=C find . -type f -name '*.ipynb' -exec sed -i '' s/begin_train/before_train/g {} +
LC_ALL=C find . -type f -name '*.ipynb' -exec sed -i '' s/begin_batch/before_batch/g {} +
LC_ALL=C find . -type f -name '*.ipynb' -exec sed -i '' s/begin_validate/before_validate/g {} +
# rebuild .py because due to updated .ipynb
nbdev_build_lib
@butchland
butchland / setup-fastai-colab-onetime-ipynb.ipynb
Last active August 31, 2020 16:02
setup-fastai-colab-onetime.ipynb.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@butchland
butchland / gist:d122ccffc83b9d8f99aa0cc37c19688f
Created November 6, 2020 11:31
RGB to Greyscale fastai vision transform
# Run this to install kornia
!pip install kornia
# create a new fastai transform
from kornia import rgb_to_grayscale
class RGB2GreyTransform(DisplayedTransform):
order = 15 # run after IntToFloatTransform
def encodes(self, o:TensorImage):
# expand restores tensor shape back to use c channels
@butchland
butchland / simple_mnist_training.ipynb
Created January 14, 2021 16:39
simple_mnist_training.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@butchland
butchland / fast-torch-tpu-wandb-pets-benchmark-large-image.ipynb
Last active February 5, 2021 08:08
wandb-fastai-callback-multi-core-tpu-error.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.