STATUS: SUPER EARLY ALPHA
This package is NOT yet ready for PUBLIC CONSUMPTION. Use at your own RISK!!!!
Everything, including the API (and even the existence of this module) are subject to breaking change...
These are utilities for adapting Pytorch/torchvision Datasets to be used in fastai TPU training.
th_train_tfms, th_test_tfms = make_torch_tfms()
all_fastai_tfms = make_cifar_item_tfm()
mixed_fastai_train_tfms = make_cifar_item_tfm(th_train_tfms)
train_tls = make_cifar_tls(cifar_dsets.CIFAR10.train_list,
cifar_root,mixed_fastai_train_tfms)
train_tls.tfms[0].x_tfm[1]
train_dl1 = make_cifar_dl(cifar_dsets.CIFAR10.train_list, cifar_root)
import torch.cuda
import torch
device = torch.device(torch.cuda.current_device()) if torch.cuda.is_available() else torch.device('cpu')
device
cifar_dls = make_fastai_cifar_dls(cifar_root, device=device)
(cifar_root/'cifar-10-batches-py').ls()
cifar_dsets.CIFAR10.train_list
xb, yb = cifar_dls.one_batch()
xb.dtype
xb.shape
yb.dtype
yb.shape
xb.device
yb.device
cifar_dls.train.after_batch
type(cifar_dls.train.dataset)
hasattr(cifar_dls, 'device')
cifar_dls.device is None
cifar_dls.path
hasattr(cifar_dls.loaders[0],'to')
cifar_dls.loaders[0].device is None
from fastai.vision.all import *
import fastai.callback.progress
from fastai.vision.models import resnet18
from fastai.metrics import accuracy
import torch.nn as nn
learner = cnn_learner(cifar_dls, resnet18, n_out=10, pretrained=False,
normalize=False,
loss_func=nn.CrossEntropyLoss(),metrics=accuracy)
learner.show_training_loop()
learner.summary()
%%time
learner.fit_one_cycle(5)