Skip to content

Instantly share code, notes, and snippets.

class ConcatDataset(Dataset):
"""Concatenates a dataset and an iterable of appropriate size."""
def __init__(self, ds, y2):
assert(len(ds)==len(y2))
self.ds,self.y2 = ds,y2
def __len__(self): return len(self.ds)
def __getitem__(self, i):
x,y = self.ds[i]
return (x, (self.y2[i],y))
def denorm(self, im): return self.ds.denorm(im)
@radekosmulski
radekosmulski / train_on_CIFAR10.py
Created June 20, 2019 19:29
training on CIFAR10 using fastai from the command line
import fire
import fastai
from fastai.vision import *
from torch import nn
from fastai.metrics import top_k_accuracy
path = untar_data(URLs.CIFAR)
data = ImageDataBunch.from_folder(path, valid='test')
class block(nn.Module):
@radekosmulski
radekosmulski / train_on_CIFAR10_fastai_only.py
Last active August 17, 2019 09:31
train on CIFAR10 in console using fastai
from fastai.vision import *
from fastai.script import *
from torch import nn
from fastai.metrics import top_k_accuracy
path = untar_data(URLs.CIFAR)
data = ImageDataBunch.from_folder(path, valid='test')
class block(nn.Module):
def __init__(self, n_in, n_out, two_d=True):
from fastai.vision import *
from fastai.script import *
from torch import nn
from fastai.metrics import top_k_accuracy
path = untar_data(URLs.CIFAR)
data = ImageDataBunch.from_folder(path, valid='test')
class block(nn.Module):
def __init__(self, n_in, n_out, two_d=True):
# from the root of fastcore:
python -c "from nbdev.cli import notebook2html; notebook2html()"
gem install jekyll bundler # need to have Ruby installed
cd docs
bundle install
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@radekosmulski
radekosmulski / install_script.sh
Created May 30, 2022 08:55
dependencies needed to install Merlin libraries
# if after running the below you still experience issues, take a look at the current
# docker image definitions here: https://github.com/NVIDIA-Merlin/Merlin/tree/main/docker
# (maybe something has changed)
sudo apt update -y --fix-missing
sudo apt install -y --no-install-recommends libexpat1-dev libsasl2-2 libssl-dev graphviz openssl protobuf-compiler software-properties-common
sudo apt autoremove -y
sudo apt clean
sudo rm -rf /var/lib/apt/lists/*
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.