Main Content


(Not recommended) SqueezeNet convolutional neural network

  • SqueezeNet network architecture

squeezenet is not recommended. Use the imagePretrainedNetwork function instead. For more information, see Version History.


SqueezeNet is a convolutional neural network that is 18 layers deep. You can load a pretrained version of the network trained on more than a million images from the ImageNet database [1]. The pretrained network can classify images into 1000 object categories, such as keyboard, mouse, pencil, and many animals. As a result, the network has learned rich feature representations for a wide range of images. This function returns a SqueezeNet v1.1 network, which has similar accuracy to SqueezeNet v1.0 but requires fewer floating-point operations per prediction [3]. The network has an image input size of 227-by-227. For more pretrained networks in MATLAB®, see Pretrained Deep Neural Networks.


net = squeezenet returns a SqueezeNet network trained on the ImageNet data set.

net = squeezenet('Weights','imagenet') returns a SqueezeNet network trained on the ImageNet data set. This syntax is equivalent to net = squeezenet.

lgraph = squeezenet('Weights','none') returns the untrained SqueezeNet network architecture.


collapse all

Load a pretrained SqueezeNet network.

net = squeezenet
net = 

  DAGNetwork with properties:

         Layers: [68×1 nnet.cnn.layer.Layer]
    Connections: [75×2 table]

This function returns a DAGNetwork object.

SqueezeNet is included within Deep Learning Toolbox™. To load other networks, use functions such as googlenet to get links to download pretrained networks from the Add-On Explorer.

Output Arguments

collapse all

Pretrained SqueezeNet convolutional neural network, returned as a DAGNetwork object.

Untrained SqueezeNet convolutional neural network architecture, returned as a LayerGraph object.


[1] ImageNet.

[2] Iandola, Forrest N., Song Han, Matthew W. Moskewicz, Khalid Ashraf, William J. Dally, and Kurt Keutzer. "SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and <0.5 MB model size." Preprint, submitted November 4, 2016.

[3] Iandola, Forrest N. "SqueezeNet."

Extended Capabilities

Version History

Introduced in R2018a

collapse all

R2024a: Not Recommended

squeezenet is not recommended. Use the imagePretrainedNetwork function instead.

There are no plans to remove support for the squeezenet function. However, the imagePretrainedNetwork function has additional functionality that helps with transfer learning workflows. For example, you can specify the number of classes in your data using the numClasses option, and the function returns a network that is ready for retraining without the need for modification.

The imagePretrainedNetwork function returns the network as a dlnetwork object, which does not store the class names, To get the class names of the pretrained network, use the second output argument of the imagePretrainedNetwork function.

This table shows some typical usages of the squeezenet function and how to update your code to use the imagePretrainedNetwork function instead.

Not RecommendedRecommended
net = squeezenet;[net,classNames] = imagePretrainedNetwork;
net = squeezenet(Weights="none");net = imagePretrainedNetwork(Weights="none");

The imagePretrainedNetwork returns a dlnetwork object, which also has these advantages:

  • dlnetwork objects are a unified data type that supports network building, prediction, built-in training, visualization, compression, verification, and custom training loops.

  • dlnetwork objects support a wider range of network architectures that you can create or import from external platforms.

  • The trainnet function supports dlnetwork objects, which enables you to easily specify loss functions. You can select from built-in loss functions or specify a custom loss function.

  • Training and prediction with dlnetwork objects is typically faster than LayerGraph and trainNetwork workflows.

To train a neural network specified as a dlnetwork object, use the trainnet function.