fast.ai 2020 — Lesson 3

# 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
An image in array and tensor
This is what the dataset looks like when also printing pixel color value
lists are turned into rank 3 tensor
This is how to get the mean 3 over all images
mean absolute difference (L1) and RMSE (L2)
tensor([1,2,3]) + 1
def pr_eight(x,w) = (x*w).sum()
# Every time xt do calculation it should remember what it was
# and then later it's easy to take derivative of that.
xt = tensor(3.).requires_grad_()
# Just some function
def f(x): return x**2
# Give xt to the function
yt = f(xt)
yt
# Prints => tensor(9., grad_fn=<PowBackward0>)
# backward takes the derivative of the previous calculation
yt.backward()
# And just to print the derivative
xt.grad()
# Prints => tensor(6.)
xt = tensor([3.,4.,10.]).requires_grad_()
def f(x): return (x**2).sum()
yt = f(xt)
yt.backward()
xt.grad
# Prints => tensor([ 6., 8., 20.])

--

--

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