Closed datalass1 closed 5 years ago
Check out the fastai notes wiki
Starts off sharing some interesting student work and blogs. Links added to issue #11 to read and understand.
Using Kaggle-cli or CurlWget Symbolic Link (SymLinks) (very handy) discussed.
Really great example of how short the code is using the fastai library.
Keras with Tensorflow in the backend requires much MUCH more code, with more settings required (copying and pasting from the web is the best way to do a lot of this), and takes longer to run the training of the model.
For the model, i.e. ResNet50, you have to set all the layer settings:
$ pip install tensorflow-gpu keras if I want to test out this code.
SGDR, differential Learning Rates, Batch Norm freezing for example would all have to be implemented in Keras to get as good results as fastai gets.
Performance is completely different. Better accuracy with both training and validation sets using fastai.
Google may import fastai into Tensorflow.
Dog Breeds and shows how to upload results to Kaggle. Insert this into the next model notebook and upload first dataset to Kaggle! #13
Also how to predict a single image.
http://setosa.io/ev/image-kernels/ https://www.youtube.com/watch?v=Oqm9vsf_hvU - otavio good visualisation of MNIST dataset
CNNs with MNIST dataset explained in an excel spreadsheet:
Softmax is typically used as our final activation layer as output. The softmax function is defined as:
exp(x)/sum(exp(x))
where x is an array of activations.
Hints: Always need to know logarithms and exponential ln(x.y) = ln(x) + ln(y) ln(x/y) = ln(x) - ln(y) ln(x) = y and exp(y) = x <-------log and exp are the inverse
Architecture - added from fastai wiki We know now from the Universal Approximation Theorem that any large enough neural network can approximate any arbitrarily complex function.....some of them can learn to solve these problems much faster than others (and will likely generalize better) by having far less parameters. This is why we care about understanding architectures such as convolutional neural networks as opposed to trying to solve every problem with deep fully connected neural networks.
satellite imagery competition from Kaggle
"anthropomorphise functions" - the softmax function wants to pick a thing. Understanding the personality of the activation function.
fastai will look at the labels in a csv and if there is more than one label, it ill automatically switch into multilabel functions.
HINT: The folder approach will not work, how can an image be in multiple folders at the same time. So we have to use the csv approach.
The images a size 256.
PyTorch will really leverage existing python functionality.
x,y = next(iter(data.val_dl))
A data loader will give you back a mini batch (a data set will give you back a single image or single object). To turn a data loader into an iterator we used a standard python function known as iter. That’s an iterator. To fetch the next minibatch pass the iter to next. An iterator/generator are similar. PyTorch is a good reason to learn Python well bs=64 (**kwarg) in tfms_from_model function so we return a mini batch of 64x17; 64 images with 17 of the possible classes.
zip is a great way of taking two lists and zip them together. Lets look at the first image with this code:
list(zip(data.classes, y[0]))
images are just matrices of numbers, so to display it better just enhance the image:
plt.imshow(data.val_ds.denorm(to_np(x))[0]*1.4);
Image size: if we use a pretrained mode (e.g. from ImageNet) it starts off nearly perfect, like in the cat vs dogs image classification problem and change the image size (sz) we will effectively kill the pretrained layers that were trained on an image size of 224 or 256. But there is nothing in ImageNet that looks like satellite imagery, exception would be for layers like finding edges and gradients or finding textures and gradient patterns. Small images for satellites like sz=64
is quite good.
Find out what learning rate to use. Because it is so unlike ImageNet lots of fitting required. The learning rate for the earlier layers is set quite high. Iterate this a few times with different image sizes and then tta at the end.
Questions at the end and to Note:
f2
is a way of weighting false negatives vs false positives. It is noted in the Kaggle competition that this is the method used to score the accuracy of the model: f beta. You can find it in courses/dl1/planet.py: the function f2 simply calls f beta score from scipy/scikit-learn. learn.summary()
to view the model and more details. Two types of data in ML:
lesson3-rossman Predicting what and how much of an item will be sold in a store(s) on a particular day.
HOMEWORK: Enter lots of Kaggle competitions, test out the fastai techniques on lots of image datasets. This will help understand the content in lesson 4.
We explain convolutional networks from several different angles: the theory, a video visualization, and an Excel demo. You’ll see how to use deep learning for structured/tabular data, such as time-series sales data.
We also teach a couple of key bits of math that you really need for deep learning: exponentiation and the logarithm. You will learn how to download data to your deep learning server, how to submit to a Kaggle competition, and key differences between PyTorch and Keras/TensorFlow.
A key advantage of neural networks as opposed to traditional machine learning techniques is that we can avoid feature engineering our raw input, i.e. constructing pre-determined features from our raw data that we think is important. (source: fastai wiki)
In training convolutional neural networks, we allow stochastic gradient descent to find optimal values for filter weights based off of the raw data itself, and in this way we've allowed our network to "learn" what the best features are from the raw data given labelled output. This is incredibly powerful, and it removes the onerous task of manually designing features. (source: fastai wiki)
Extra stuff I found: