This article is about how I tested a hypothesis I had by building a website in 3 days. It’s not my first time building something to test business hypothesis but this time I wanted to do it faster and document the processes.

Hypothesis

The hypothesis is that people enjoy commenting 💩…

fastai/fastbook

Language model = a model that tries to predict the next word of a sentence.

A language model works well on transfer learning as the base model because it knows something about language as it can predict the next word of a sentence.

Wikipedia language model is often the starting point

The base language model should be…

fastai/fastbook

learn = cnn_learner(dls, resnet34, metrics=error_rate)
learn.fine_tune(2, base_lr=0.1)

Learning rate finder helps to pick the best learning rate. The idea is to change the learning rate after every mini-batch and then plot the loss. Good learning rate is somewhere between the steepest point and the minimum. So for example based…

fastai/fastbook

Create dataset

train_x = torch.cat([stacked_threes, stacked_sevens]).view(-1, 28*28)
train_y = tensor([1] * len(threes) + [0] * len(sevens)).unsqueeze(1)
print(train_x.shape, train_y.shape)
CONSOLE: (torch.Size([12396, 784]), torch.Size([12396, 1]))
dset = list(zip(train_x, train_y))
x, y = dset[0]
print(x.shape, y)
PRINT: (torch.Size([784]), tensor([1]))

Create weights

def init_params(size, variance=1.0):
return (torch.randn(size)*variance).requires_grad_()
weights = init_params((28*28,1))
bias = init_params(1)

fastai/fastbook

# Load saved learner
learn_inf = load_learner(path/'export.pkl')
# Predict given image
learn_inf.predict('images/grizzly.jpg')
# See labels
learn_inf.dls.vocab

Jupyter Notebook widgets are created using IPython widgets.

Deploying CPU is easier than GPU in most of the cases. GPU is needed only if the deployed model still requires a lot of computation…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store