<jupyter_start><jupyter_text><jupyter_code>!curl -s https://course19.fast.ai/setup/colab | bash
!pip install -Uqq fastcore --upgrade
!pip install -Uqq fastai --upgrade
!pip install -Uqq fastai_xla_extensions
!pip install -Uqq cloud-tpu-client==0.10 https://storage.googleapis.com/tpu-pytorch/wheels/torch_xla-1.7-cp36-cp36m-linux_x86_64.whl
# VERSION = "20200325" #@param ["1.5" , "20200707", "20200325", "nightly"]
# !curl https://raw.githubusercontent.com/pytorch/xla/master/contrib/scripts/env-setup.py -o pytorch-xla-env-setup.py > /dev/null
# !python pytorch-xla-env-setup.py --version $VERSION > /dev/null
!pip freeze | grep torch
!pip freeze | grep fast
from fastai.tabular.all import *
import fastai_xla_extensions.core
path = untar_data(URLs.ADULT_SAMPLE)
Path.BASE_PATH = path
df = pd.read_csv(path/'adult.csv')
dls = TabularDataLoaders.from_csv(path/'adult.csv', path=path, y_names="salary",
    cat_names = ['workclass', 'education', 'marital-status', 'occupation', 'relationship', 'race'],
    cont_names = ['age', 'fnlwgt', 'education-num'],
    procs = [Categorify, FillMissing, Normalize])
dls.device
learn = tabular_learner(dls, metrics=accuracy)
learn.to_xla() 

learn.fit_one_cycle(15)
learn.recorder.plot_loss()
learn.predict(df.iloc[0])
test_df = df.copy()
test_df.drop(['salary'], axis=1, inplace=True)
dl = learn.dls.test_dl(test_df)
learn.get_preds(dl=dl)
learn.dls.device
one_param(learn.model).device<jupyter_output><empty_output><jupyter_text>**End of Notebook**<jupyter_code><jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16177429876060012, 'fraction_numerical': 0.029354207436399216, 'mean_word_length': 5.90990990990991, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '434790', 'license': 'Apache-2.0', 'n_tokens_mistral': 642, 'n_tokens_neox': 606, 'n_words': 98, 'path': 'samples/TabularTrainingTPUdemo.ipynb', 'repo_name': 'tyoc213/fastai_xla_extensions', 'size': '1533'}