Wolfram Neural Net Repository
Immediate Computable Access to Neural Net Models
Identify the main object in an image
Released in 2017 by researchers at Google, these models were designed for mobile and embedded vision applications. Depthwise separable convolutions are used to build light and efficient networks.
Number of models: 16
Comparison of multiply-and-accumulate operations (MACs), number of parameters and top-1/top-5 accuracies for all models. Models are referenced by Width-InputResolution parameter pairs:
Get the pre-trained net:
In[1]:= | ![]() |
Out[1]= | ![]() |
This model consists of a family of individual nets, each identified by a specific parameter combination. Inspect the available parameters:
In[2]:= | ![]() |
Out[2]= | ![]() |
Pick a non-default net by specifying the parameters:
In[3]:= | ![]() |
Out[3]= | ![]() |
Pick a non-default uninitialized net:
In[4]:= | ![]() |
Out[4]= | ![]() |
Classify an image:
In[5]:= | ![]() |
Out[5]= | ![]() |
The prediction is an Entity object, which can be queried:
In[6]:= | ![]() |
Out[6]= | ![]() |
Get a list of available properties of the predicted Entity:
In[7]:= | ![]() |
Out[7]= | ![]() |
Obtain the probabilities of the 10 most likely entities predicted by the net:
In[8]:= | ![]() |
Out[8]= | ![]() |
An object outside the list of the ImageNet classes will be misidentified:
In[9]:= | ![]() |
Out[9]= | ![]() |
Obtain the list of names of all available classes:
In[10]:= | ![]() |
Out[10]= | ![]() |
Remove the last layers of the trained net so that the net produces a vector representation of an image:
In[11]:= | ![]() |
Out[11]= | ![]() |
Get a set of images:
In[12]:= | ![]() |
Visualize the features of a set of images:
In[13]:= | ![]() |
Out[13]= | ![]() |
Extract the weights of the first convolutional layer in the trained net:
In[14]:= | ![]() |
Out[14]= | ![]() |
In[15]:= | ![]() |
Show the dimensions of the weights:
In[16]:= | ![]() |
Out[16]= | ![]() |
Visualize the weights as a list of 32 images of size 3x3:
In[17]:= | ![]() |
Out[17]= | ![]() |
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:
In[18]:= | ![]() |
In[19]:= | ![]() |
Remove the last layers from the pre-trained net:
In[20]:= | ![]() |
Out[20]= | ![]() |
Create a new net composed of the pre-trained net followed by a linear layer and a softmax layer:
In[21]:= | ![]() |
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):
In[22]:= | ![]() |
Out[22]= | ![]() |
Perfect accuracy is obtained on the test set:
In[23]:= | ![]() |
Out[23]= | ![]() |
Inspect the number of parameters of all arrays in the net:
In[24]:= | ![]() |
Out[24]= | ![]() |
Obtain the total number of parameters:
In[25]:= | ![]() |
Out[25]= | ![]() |
Obtain the layer type counts:
In[26]:= | ![]() |
Out[26]= | ![]() |
Wolfram Language 12.2 (December 2020) or above