Wolfram Neural Net Repository
Immediate Computable Access to Neural Net Models
Identify the main object in an image
Number of layers: 46 | Parameter count: 143,667,240 | Trained size: 575 MB |
This model achieves 75.2% top-1 and 92.5% top-5 accuracy on the ImageNet Large Scale Visual Recognition Challenge 2012 dataset.
Get the pre-trained net:
In[1]:= | ![]() |
Out[1]= | ![]() |
Classify an image:
In[2]:= | ![]() |
Out[2]= | ![]() |
The prediction is an Entity object, which can be queried:
In[3]:= | ![]() |
Out[3]= | ![]() |
Get a list of available properties of the predicted Entity:
In[4]:= | ![]() |
Out[4]= | ![]() |
Obtain the probabilities of the ten most likely entities predicted by the net:
In[5]:= | ![]() |
Out[5]= | ![]() |
An object outside the list of the ImageNet classes will be misidentified:
In[6]:= | ![]() |
Out[6]= | ![]() |
Obtain the list of names of all available classes:
In[7]:= | ![]() |
Out[7]= | ![]() |
Remove the last three layers of the trained net, so that the net produces a vector representation of an image:
In[8]:= | ![]() |
Out[8]= | ![]() |
Get a set of images:
In[9]:= | ![]() |
Visualize the features of a set of images:
In[10]:= | ![]() |
Out[10]= | ![]() |
Extract the weights of the first convolutional layer in the trained net:
In[11]:= | ![]() |
Visualize the weights as a list of 64 images of size 3x3:
In[12]:= | ![]() |
Out[12]= | ![]() |
Use the pre-trained model to build a classifier for telling apart images of dogs and cats. Create a test set and a training set:
In[13]:= | ![]() |
In[14]:= | ![]() |
Remove the linear layer from the pre-trained net:
In[15]:= | ![]() |
Out[15]= | ![]() |
Create a new net composed of the pre-trained net followed by a linear layer and a softmax layer:
In[16]:= | ![]() |
Out[16]= | ![]() |
Train on the dataset, freezing all the weights except for those in the "linearNew" layer (use TargetDevice -> "GPU" for training on a GPU):
In[17]:= | ![]() |
Out[17]= | ![]() |
Perfect accuracy is obtained on the test set:
In[18]:= | ![]() |
Out[18]= | ![]() |
Inspect the number of parameters of all arrays in the net:
In[19]:= | ![]() |
Out[19]= | ![]() |
Obtain the total number of parameters:
In[20]:= | ![]() |
Out[20]= | ![]() |
Obtain the layer type counts:
In[21]:= | ![]() |
Out[21]= | ![]() |
Display the summary graphic:
In[22]:= | ![]() |
Out[22]= | ![]() |
Export the net into a format that can be opened in MXNet:
In[23]:= | ![]() |
Out[23]= | ![]() |
Export also creates a net.params file containing parameters:
In[24]:= | ![]() |
Out[24]= | ![]() |
Get the size of the parameter file:
In[25]:= | ![]() |
Out[25]= | ![]() |
The size is similar to the byte count of the resource object:
In[26]:= | ![]() |
Out[26]= | ![]() |
Represent the MXNet net as a graph:
In[27]:= | ![]() |
Out[104]= | ![]() |
Out[27]= | ![]() |
Wolfram Language 11.2 (September 2017) or above