Wolfram Neural Net Repository
Immediate Computable Access to Neural Net Models
Identify the main object in an image
Get the pre-trained net:
In[1]:= | ![]() |
Out[2]= | ![]() |
This model consists of a family of individual nets, each identified by a specific parameter combination. Inspect the available parameters:
In[3]:= | ![]() |
Out[4]= | ![]() |
Pick a non-default net by specifying the parameters:
In[5]:= | ![]() |
Out[6]= | ![]() |
Pick a non-default uninitialized net:
In[7]:= | ![]() |
Out[8]= | ![]() |
Classify an image:
In[9]:= | ![]() |
In[10]:= | ![]() |
Out[11]= | ![]() |
The prediction is an Entity object, which can be queried:
In[12]:= | ![]() |
Out[12]= | ![]() |
Get a list of available properties of the predicted Entity:
In[13]:= | ![]() |
Out[13]= | ![]() |
Obtain the probabilities of the 10 most likely entities predicted by the net:
In[14]:= | ![]() |
Out[15]= | ![]() |
An object outside the list of the ImageNet classes will be misidentified:
In[16]:= | ![]() |
Out[17]= | ![]() |
Obtain the list of names of all available classes:
In[18]:= | ![]() |
Out[19]= | ![]() |
Remove the last two layers of the trained net so that the net produces a vector representation of an image:
In[20]:= | ![]() |
Out[21]= | ![]() |
Get a set of images:
In[22]:= | ![]() |
In[23]:= | ![]() |
Visualize the features of a set of images:
In[24]:= | ![]() |
Out[24]= | ![]() |
Use the pre-trained model to build a classifier for telling apart images of bulbs and cameras. Create a test set and a training set:
In[25]:= | ![]() |
In[26]:= | ![]() |
Remove the last classification layers from the pre-trained net:
In[27]:= | ![]() |
Out[28]= | ![]() |
Create a new net composed of the pre-trained net followed by a linear layer and a softmax layer:
In[29]:= | ![]() |
Out[29]= | ![]() |
Train on the dataset, freezing all the weights except for those in the "linearNew" layer (use TargetDevice -> "GPU" for training on a GPU):
In[30]:= | ![]() |
Out[30]= | ![]() |
Perfect accuracy is obtained on the test set:
In[31]:= | ![]() |
Out[31]= | ![]() |
Inspect the number of parameters of all arrays in the net:
In[32]:= | ![]() |
Out[33]= | ![]() |
Obtain the total number of parameters:
In[34]:= | ![]() |
Out[35]= | ![]() |
Obtain the layer type counts:
In[36]:= | ![]() |
Out[37]= | ![]() |
Display the summary graphic:
In[38]:= | ![]() |
Out[39]= | ![]() |
Export the net to the ONNX format:
In[40]:= | ![]() |
Out[41]= | ![]() |
Get the size of the ONNX file:
In[42]:= | ![]() |
Out[42]= | ![]() |
The size is similar to the byte count of the resource object:
In[43]:= | ![]() |
Out[44]= | ![]() |
Check some metadata of the ONNX model:
In[45]:= | ![]() |
Out[45]= | ![]() |
Import the model back into Wolfram Language. However, the NetEncoder and NetDecoder will be absent because they are not supported by ONNX:
In[46]:= | ![]() |
Out[46]= | ![]() |