stouputils.data_science.models.keras.squeezenet module#

SqueezeNet model implementation.

This module provides a wrapper class for the SqueezeNet model, a lightweight CNN architecture that achieves AlexNet-level accuracy with 50x fewer parameters and a model size of less than 0.5MB. SqueezeNet uses “fire modules” consisting of a squeeze layer with 1x1 filters followed by an expand layer with a mix of 1x1 and 3x3 convolution filters.

Available models: - SqueezeNet: Compact model with excellent performance-to-parameter ratio

The model supports transfer learning from ImageNet pre-trained weights.

fire_module(x: Any, fire_id: int, squeeze: int = 16, expand: int = 64)[source]#

Create a fire module with specified parameters.

Parameters:
  • x (Tensor) – Input tensor

  • fire_id (int) – ID for the fire module

  • squeeze (int) – Number of filters for squeeze layer

  • expand (int) – Number of filters for expand layers

Returns:

Output tensor from the fire module

Return type:

Tensor

SqueezeNet_keras(include_top: bool = True, weights: str = 'imagenet', input_tensor: Any | None = None, input_shape: tuple[Any, ...] | None = None, pooling: str | None = None, classes: int = 1000) Model[source]#

Instantiates the SqueezeNet architecture.

Parameters:
  • include_top (bool) – Whether to include the fully-connected layer at the top

  • weights (str) – One of None or ‘imagenet’

  • input_tensor (Tensor) – Optional Keras tensor as input

  • input_shape (tuple) – Optional shape tuple

  • pooling (str) – Optional pooling mode for feature extraction

  • classes (int) – Number of classes to classify images into

Returns:

A Keras model instance

Return type:

Model

class SqueezeNet(num_classes: int, kfold: int = 0, transfer_learning: str = 'imagenet', **override_params: Any)[source]#

Bases: BaseKeras

SqueezeNet implementation using advanced model class with common functionality. For information, refer to the ModelInterface class.

class_routine(kfold: int = 0, transfer_learning: str = 'imagenet', verbose: int = 0, **override_params: Any) ModelInterface#

Run the full routine for SqueezeNet model.

Parameters:
  • dataset (Dataset) – Dataset to use for training and evaluation.

  • kfold (int) – K-fold cross validation index.

  • transfer_learning (str) – Pre-trained weights to use, can be “imagenet” or a dataset path like ‘data/pizza_not_pizza’.

  • verbose (int) – Verbosity level.

  • **kwargs (Any) – Additional arguments.

Returns:

Trained model instance.

Return type:

SqueezeNet

model#

alias of SqueezeNet