Can we learn deep learning in depth by just experimenting working examples?
- learn source codes of tf with example on VGG16
- minimum comment on source codes
- Notebook to show process example by fast.ai
- process of image data going through each filter or layer
- process of weights update through running each sample
- process of effects of small and large learning rate
- core tf.contrib.keras building VGG16
- uniqueness about imagenet datasets for this task
- one central object in each image
- rest is background or environment
- nature of the problem:
- inputs:lots of images, each contain a central object
- return: an object-name of 1000 object-names
- VGG16 use many layers of filters to screen the same image with different features (of different depths and focus)
- weights and layers are to capture the correlation between inputs and output
when you don't have large images datasets and huge GPU computing power
- prepare data
- build model
- load weights
when you have a small datasets of your own (correctly labeled for training)
- finetune
- train
- predict
what if there is no readily labeled datasets, but unlabeled images and videos
- find useful weights or layers (e.g. weights or layers to detect vertically flying object)
- build model using those specific weights and layers
- use model to filter out interesting images
-
how to prepare images into train, valid, test, sample folders notebook
-
convert train|valid|test|sample folder into batch_iterator objects source
-
convert images in folders to batches then to a large array: source
- how to create vgg16 model instance from
tf.contrib.keras
source
-
fine_tune1: just replace the last layer: source
-
fine_tune2: replace the last layer and add an additional dense layer before the last layer source
-
train or fit vgg16 model: source
-
save-load model+weights, save-load model, save-load weights, load old and make new model, load weights to a new model: source
-
load, train_again, and save vgg16 model: source
-
save large arrays with maximum memory efficiency: source
- for the same large array to be saved,
bcolz
can shrink its size by 4 times smaller than file saved bynumpy
,pickle
,torch
,kur.idx
- for the same large array to be saved,
-
load vgg16 model, predict with test batches, and save preds: source
-
np.clip
,log-loss
,ids-pred
array: source- why and how to clip predictions
- extract image ids and cbind ids with predictions
- how log-loss or cross-entropy behave against predictions
-
build model with Sequential: source
-
vgg16 model decode preds for 1000 classes: source
-
process image dataset for vgg16? source
-
how to call a keras function manually to test it? forum
-
(todo) how to plot source
- A few correct labels at random
- A few incorrect labels at random
- The most correct labels of each class (ie those with highest probability that are correct)
- The most incorrect labels of each class (ie those with highest probability that are incorrect)
- The most uncertain labels (ie those with probability closest to 0.5).
- confusion matrix
- (kr1.2) how to finetune vgg16 with new set of classes fast.ai source
-
most noble goal of fast ai course: fast.ai.wiki
-
why VGG16 preprocess images that way: fast.ai.forum
- mean and order of RGB are prefixed
-
how to apply VGG to catsdogs problem: fast.ai
-
why do batch training: fast.ai
-
(kr) how to switch from theano to tf backend, and switch cpu and gpu in theano: fast.ai
-
why study state-of-art models like VGG: fast.ai
-
7 steps to recognize basic images using vgg16: fast.ai
-
how to see limit and bias of a pretrained model like vgg16: fast.ai
-
What is finetune to a pretrained model like vgg16? fast.ai
-
Why create a sample/train,valid,test folders from full dataset? fast.ai
-
how to count number of files in a folder:
ls folder/ | wc -l
-
how to unzip a zip file:
unzip -q data.zip
-
how to check python version:
which python
-
how to organize dataset before training: source
- train, test, sample folder
- sample: train, valid, test subfolders
- experiment codes on sample dataset
-
how to check the first few files of a folder:
ls folder/ | head
-
how to submit to kaggle: fast.ai
-
how to use kaggle cli to download and submit #@F: source
-
make a todo list before working on any project or problem
-
how to prepare data after downloaded from kaggle? fast.ai.wiki
-
why we need save weights other than save model?
- Answer: with save, load empty model, save and load only weights, we can load weights to the same or even a different model keras doc
-
how to submit to kaggle using
keras.predict_generator
andFileLink
: wiki -
why clip the final predictions for better log loss measurement? wiki
-
what does CNNs learn fast.ai video
- beautifully explained
- it seems very useful to view all layers and weights of vgg16
- (todo) check forum for similar questions
- (todo) do it myself with my own prewritten functions
-
how deep learning work in excel? fast.ai video
- (todo) display in excel how input layer and weights layer create output | activation layer
- (todo) display how to do Axier initialization on weights
-
how to visualize SGD gradually optimize weights to plot the correct line? fast.ai video
- (todo) rewrite to numpy code
- (todo) keras on linear model with SGD
-
how to efficient save and load large arrays; save, load, plot from images files in folders; do one_hot encoding fast.ai video
- (todo) use
bcolz
to efficiently save and load predictions array - (todo) get batches of images loaded from folders into proper arrays
- (todo) save, load, plot those arrays into images
- (todo) do one_hot encoding
- (todo) use
-
how to use a single dense network with Vgg16 model's power? fast.ai video
- (todo) use keras Sequential, Dense and vgg16's outputs
-
power of activation layer - non-linear function fast.ai video
- input dot weights == linear model
- activation function == non-linear model
- activation func make deep learning powerful
-
(todo) how to visualize model as dots: forum
- source
- not useful at all,
model.summary()
can do a better job, seemingly
- not useful at all,
- source
-
challenges:
- (todo) dissect every line of
vgg16()
- (todo) dissect every line of
-
how to experiment the notebook video
- write the source code
- experiment for 30 minutes,, check questions and answers on wiki and forum
- then ask questions on forum
-
better explain the usage of deep viz toolbox video
- (todo) install and try as the video do
- (todo) can this apply to RNN? and other neuralnets?
- (todo later) there are vis tools on RNN too
-
understand cnn with spreadsheet and notebook: video
- (todo) spreadsheet: compare Dense with Conv on create activation layer
- (todo) notebook: explain Conv, Pad, and Pool in steps
- (todo) convert notebook to spreadshee: spreadsheet is more intuitive displaying
-
review VGG: video
- (todo) demo the above todo task with vgg16 model example
-
maxpooling, padding: video
- (todo) spreadsheet and notebook: maxpool lose pixel, and layer goes deep, filter shrink size further, but activation layer becomes more high concept recognisable images?
- how to make sense of it all
-
softmax with spreadshee: video
- (todo)
-
review SGD notebook: video
- (todo) intuition: how sgd or derivative help update weight, bias to the optimal weight and bias of target
- (todo) convert notebook to spreadsheet?
-
how to decide on filter size and num_fitlers: video
- practically, filter size (3,3)
- num_fitlers: not yet finalized
- how to deal with much larger images:
- not yet finalized: help from attention with LSTM to mimic how actual eye work?
-
how to retrain vgg16 with more layers? video
- (todo) how many layers to make trainable?
- intuition: knowing which layer does what through weights vis
- experiment to see what works better
- vgg16 retain 1 dense layer for dogscats, retain 3 dense layers for statefarm dataset, as CNN layers are positional invariance oriented.
- (todo) how many layers to make trainable?
-
understand under and overfitting: wiki
- underfitting: use linear model to do vgg16's job, use far too less parameters to take on more complex problems, in the end error for both training and validation are still very high
- overfitting: use too many parameters to take on relatively simpler problems, in the end training loss is very low, but val_loss is higher
-
what dropout layer do: video and wiki
- drop out 50% neurons, model won't get overfit even though model has a huge number of neurons
- in vgg16 dogscats case, 50% is too much, and made model underfitting, so drop 50% to 10% maybe can avoid underfitting
- dropout: like ensemble, is to create many smaller but different models
-
split vgg16 into 2 models: video
- (todo) split to a cnn model
- don't change anything in cnn model, as it is expensive to train cnn model weights
- (todo) split to a dense model: do change dense model as you like, it is cheaper to train
- (todo) split to a cnn model
-
how to do data augumentation: video
- help reduce overfitting
- how to rotate or augumentation on your dataset
- (todo) make it your own
-
how to do batch normalization: video
- why normalize inputs:
- cos if inputs have different scales, it is harder to train and loss can mess up and too high, so ALWAYS normalize your inputs
- why do batch normalization:
- 10 faster
- reduce overfitting
- what is batch normalization:
- normalize not inputs but intermediate layers
- apply two trainable parameters to each layer: arbitrary std and mean
- (todo) cnn inputs + dense model + batch_normalization and train this new model
- why normalize inputs:
-
(todo) end-to-end model building process with mnist: video
- load mnist dataset
- onehot label
- normalize inputs
- single dense model, 1-hidden dense model on mnist
- vgg-style simple cnn model video
- make sure the model is capable of some overfitting, then try to reduce overfitting
- data augmentation, batch_normalization on every layer(do understand the source), dropout
- ensembling
-
challenge: statefarm solutions
-
(tf) how to use math ops: source
-
how to create histogram plot: source
-
(tf) how to create random dataset: source
-
(tf) how to make a sequence with
tf.linspace
,tf.range
: sourcenp.linspace
andrange
can do iterations- not for
tf.linspace
,tf.range
-
(tf) how to use
tf.ones
,tf.ones_like
,tf.zeros
,tf.zeros_like
,tf.fill
: source -
(tf) how to use
tf.constant
and tricks: source -
(tf) how to use
sess
,graph
, to display ops intensorboard
: source
-
how to do subplots without space in between: source
-
how to quick-plot stock csv (use full csv path, plot close and volume right away): source
-
how to stock csv with date (csv to vec object, date formatter): source
-
how to reverse a list or numpy array?
list(reversed(your_list))
your_array[::-1]
-
how to gridsubplot (stock chart like subplots): source
-
how to subplot (4 equal subplots, 1 large + 3 small subplots): source
-
how to plot images (array shape for image, interpolation, cmap, origin studied): source
-
how to plot contour map (not studied): source
-
how to plot bars (set facecolor, edgecolor, text loc for each bar, ticks, xlim): source
-
how to do scatter plot (set size, color, alpha, xlim, ignore ticks): source
-
how to set x,y ticks labels fontsize, color, alpha: source
-
how to add annotation or text: source
-
how to add labels to lines and change labels when setting legend: source
-
how to reposition x,y axis anywhere with
plt.gca()
,ax.spines
,ax.xaxis
: source -
how to set line params, xlim, xticks: source
-
how to plot subplots of 4 activation lines: source
-
torch activations sources
-
torch Variables: source
-
torch.tensor vs numpy: source
-
read stocks csv:
-
train cnn net: source
-
train rnn net: source
-
build rnn net: source
-
build cnn net: source
-
prepare_mnist: source
-
100 exercises to numpy: source
-
pandas exercises: source
-
how to save and load numpy arrays with numpy: doc example
- regression on fake 1d dataset:
- classification on fake 1d dataset:
- cnn on mnist: