Resource retrieval
Get the pre-trained net:
Out[1]= | |
NetModel parameters
This model consists of a family of individual nets, each identified by a specific parameter combination. Inspect the available parameters:
Out[2]= | |
Pick a non-default net by specifying the parameters:
Out[3]= | |
Pick a non-default uninitialized net:
Out[4]= | |
Basic usage
Classify an image:
Out[5]= | |
The prediction is an Entity object, which can be queried:
Out[6]= | |
Get a list of available properties of the predicted Entity:
Out[7]= | |
Obtain the probabilities of the 10 most likely entities predicted by the net:
Out[8]= | |
An object outside the list of the ImageNet classes will be misidentified:
Out[9]= | |
Obtain the list of names of all available classes:
Out[10]= | |
Feature extraction
Remove the last two layers of the trained net so that the net produces a vector representation of an image:
Out[11]= | |
Get a set of images:
Visualize the features of a set of images:
Out[13]= | |
Visualize convolutional weights
Extract the weights of the first convolutional layer in the trained net:
Out[14]= | |
Show the dimensions of the weights:
Out[16]= | |
Visualize the weights as a list of 64 images of size 3x3:
Out[17]= | |
Transfer learning
Use the pre-trained model to build a classifier for telling apart images of motorcycles and bicycles. Create a test set and a training set:
Remove the linear layer from the pre-trained net:
Out[20]= | |
Create a new net composed of the pre-trained net followed by a linear layer and a softmax layer:
Out[21]= | |
Train on the dataset, freezing all the weights except for those in the "linearNew" layer (use TargetDevice -> "GPU" for training on a GPU):
Out[22]= | |
Perfect accuracy is obtained on the test set:
Out[23]= | |
Net information
Inspect the number of parameters of all arrays in the net:
Out[24]= | |
Obtain the total number of parameters:
Out[25]= | |
Obtain the layer type counts:
Out[26]= | |
Export to MXNet
Export the net into a format that can be opened in MXNet:
Out[28]= | |
Export also creates a net.params file containing parameters:
Out[29]= | |
Get the size of the parameter file:
Out[30]= | |