sparseml.tensorflow_v1.models.classification package

Submodules

sparseml.tensorflow_v1.models.classification.mnist module

sparseml.tensorflow_v1.models.classification.mnist.mnist_net(inputs: tensorflow.python.framework.ops.Tensor, num_classes: int = 10, act: Optional[str] = None)tensorflow.python.framework.ops.Tensor[source]

A simple convolutional model created for the MNIST dataset

Parameters
  • inputs – the inputs tensor to create the network for

  • num_classes – the number of classes to create the final layer for

  • act – the final activation to use in the model, supported: [None, relu, sigmoid, softmax]

Returns

the logits output from the created network

sparseml.tensorflow_v1.models.classification.mobilenet module

TensorFlow MobileNet implementations. Further info can be found in the paper here.

class sparseml.tensorflow_v1.models.classification.mobilenet.MobileNetSection(num_blocks: int, out_channels: int, downsample: bool)[source]

Bases: object

Settings to describe how to put together a MobileNet architecture using user supplied configurations.

Parameters
  • num_blocks – the number of depthwise separable blocks to put in the section

  • out_channels – the number of output channels from the section

  • downsample – True to apply stride 2 for down sampling of the input, False otherwise

create(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], kernel_initializer, bias_initializer, beta_initializer, gamma_initializer)tensorflow.python.framework.ops.Tensor[source]

Create the section in the current graph and scope

Parameters
  • name – the name for the scope to create the section under

  • x_tens – The input tensor to the MobileNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the section

sparseml.tensorflow_v1.models.classification.mobilenet.mobilenet(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: str = 'single', kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

Standard MobileNet implementation with width=1.0; expected input shape is (B, 224, 224, 3)

Parameters
  • inputs – The input tensor to the MobileNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.mobilenet.mobilenet_const(x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], sec_settings: List[sparseml.tensorflow_v1.models.classification.mobilenet.MobileNetSection], num_classes: int, class_type: str, kernel_initializer, bias_initializer, beta_initializer, gamma_initializer)tensorflow.python.framework.ops.Tensor[source]

Graph constructor for MobileNet implementation.

Parameters
  • x_tens – The input tensor to the MobileNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • sec_settings – The settings for each section in the MobileNet modoel

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.mobilenet_v2 module

TensorFlow MobileNet V2 implementations. Further info can be found in the paper here.

class sparseml.tensorflow_v1.models.classification.mobilenet_v2.MobileNetV2Section(num_blocks: int, out_channels: int, downsample: bool, exp_channels: Optional[int] = None, exp_ratio: float = 1.0, init_section: bool = False, width_mult: float = 1.0)[source]

Bases: object

Settings to describe how to put together MobileNet V2 architecture using user supplied configurations.

Parameters
  • num_blocks – the number of inverted bottleneck blocks to put in the section

  • out_channels – the number of output channels from the section

  • downsample – True to apply stride 2 for down sampling of the input, False otherwise

  • exp_channels – number of channels to expand out to, if not supplied uses exp_ratio

  • exp_ratio – the expansion ratio to use for the depthwise convolution

  • init_section – True if it is the initial section, False otherwise

  • width_mult – The width multiplier to apply to the channel sizes

create(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], kernel_initializer, bias_initializer, beta_initializer, gamma_initializer)tensorflow.python.framework.ops.Tensor[source]

Create the section in the current graph and scope

Parameters
  • name – the name for the scope to create the section under

  • x_tens – The input tensor to the MobileNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the section

sparseml.tensorflow_v1.models.classification.mobilenet_v2.mobilenet_v2(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

Standard MobileNet V2 implementation with width=1.0; expected input shape is (B, 224, 224, 3)

Parameters
  • inputs – The input tensor to the MobileNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.mobilenet_v2.mobilenet_v2_const(x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], sec_settings: List[sparseml.tensorflow_v1.models.classification.mobilenet_v2.MobileNetV2Section], num_classes: int, class_type: str, kernel_initializer, bias_initializer, beta_initializer, gamma_initializer)tensorflow.python.framework.ops.Tensor[source]

Graph constructor for MobileNet V2 implementation.

Parameters
  • x_tens – The input tensor to the MobileNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • sec_settings – The settings for each section in the MobileNet modoel

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.mobilenet_v2.mobilenet_v2_width(width_mult: float, inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

Standard MobileNetV2 implementation for a given width; expected input shape is (B, 224, 224, 3)

Parameters
  • width_mult – The width multiplier for the architecture to create. 1.0 is standard, 0.5 is half the size, 2.0 is twice the size.

  • inputs – The input tensor to the MobileNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.resnet module

TensorFlow ResNet implementation. Further info on ResNet can be found in the paper here.

class sparseml.tensorflow_v1.models.classification.resnet.ResNetSection(num_blocks: int, out_channels: int, downsample: bool, proj_channels: int = - 1)[source]

Bases: object

Settings to describe how to put together a ResNet based architecture using user supplied configurations.

Parameters
  • num_blocks – the number of blocks to put in the section (ie Basic or Bottleneck blocks)

  • out_channels – the number of output channels from the section

  • downsample – True to apply stride 2 for downsampling of the input, False otherwise

  • proj_channels – The number of channels in the projection for a bottleneck block, if < 0 then uses basic

create(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], kernel_initializer, bias_initializer, beta_initializer, gamma_initializer)tensorflow.python.framework.ops.Tensor[source]

Create the section in the current graph and scope

Parameters
  • name – the name for the scope to create the section under

  • x_tens – The input tensor to the ResNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the section

sparseml.tensorflow_v1.models.classification.resnet.resnet101(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

Standard ResNet101 implementation; expected input shape is (B, 224, 224, 3)

Parameters
  • inputs – The input tensor to the ResNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.resnet.resnet152(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

Standard ResNet152 implementation; expected input shape is (B, 224, 224, 3)

Parameters
  • inputs – The input tensor to the ResNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.resnet.resnet18(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

Standard ResNet18 implementation; expected input shape is (B, 224, 224, 3)

Parameters
  • inputs – The input tensor to the ResNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.resnet.resnet20(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 10, class_type: str = 'single', kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]
sparseml.tensorflow_v1.models.classification.resnet.resnet34(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

Standard ResNet34 implementation; expected input shape is (B, 224, 224, 3)

Parameters
  • inputs – The input tensor to the ResNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.resnet.resnet50(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

Standard ResNet50 implementation; expected input shape is (B, 224, 224, 3)

Parameters
  • inputs – The input tensor to the ResNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.resnet.resnet_const(x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], sec_settings: List[sparseml.tensorflow_v1.models.classification.resnet.ResNetSection], num_classes: int, class_type: str, kernel_initializer, bias_initializer, beta_initializer, gamma_initializer, simplified_arch: bool = False)tensorflow.python.framework.ops.Tensor[source]

Graph constructor for ResNet implementation.

Parameters
  • x_tens – The input tensor to the ResNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • sec_settings – The settings for each section in the ResNet modoel

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

  • simplified_arch – Whether the network is a simplified version for the Cifar10/100 dataset

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.vgg module

PyTorch VGG implementations. Further info can be found in the paper here.

class sparseml.tensorflow_v1.models.classification.vgg.VGGSection(num_blocks: int, out_channels: int, use_batchnorm: bool)[source]

Bases: object

Settings to describe how to put together a VGG architecture using user supplied configurations.

Parameters
  • num_blocks – the number of blocks to put in the section (conv [bn] relu)

  • out_channels – the number of output channels from the section

  • use_batchnorm – True to put batchnorm after each conv, False otherwise

create(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], kernel_initializer, bias_initializer, beta_initializer, gamma_initializer)tensorflow.python.framework.ops.Tensor[source]

Create the section in the current graph and scope

Parameters
  • name – the name for the scope to create the section under

  • x_tens – The input tensor to the MobileNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the section

sparseml.tensorflow_v1.models.classification.vgg.vgg11(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

Standard VGG 11 implementation; expected input shape is (B, 224, 224, 3)

Parameters
  • inputs – The input tensor to the MobileNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.vgg.vgg11bn(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

Standard VGG 11 batch normalized implementation; expected input shape is (B, 224, 224, 3)

Parameters
  • inputs – The input tensor to the MobileNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.vgg.vgg13(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

Standard VGG 13 implementation; expected input shape is (B, 224, 224, 3)

Parameters
  • inputs – The input tensor to the MobileNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.vgg.vgg13bn(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

Standard VGG 13 batch normalized implementation; expected input shape is (B, 224, 224, 3)

Parameters
  • inputs – The input tensor to the MobileNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.vgg.vgg16(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

Standard VGG 16 implementation; expected input shape is (B, 224, 224, 3)

Parameters
  • inputs – The input tensor to the MobileNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.vgg.vgg16bn(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

Standard VGG 16 batch normalized implementation; expected input shape is (B, 224, 224, 3)

Parameters
  • inputs – The input tensor to the MobileNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.vgg.vgg19(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

Standard VGG 19 implementation; expected input shape is (B, 224, 224, 3)

Parameters
  • inputs – The input tensor to the MobileNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.vgg.vgg19bn(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

Standard VGG 19 batch normalized implementation; expected input shape is (B, 224, 224, 3)

Parameters
  • inputs – The input tensor to the MobileNet architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

sparseml.tensorflow_v1.models.classification.vgg.vgg_const(x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], sec_settings: List[sparseml.tensorflow_v1.models.classification.vgg.VGGSection], num_classes: int, class_type: str, kernel_initializer, bias_initializer, beta_initializer, gamma_initializer)tensorflow.python.framework.ops.Tensor[source]

Graph constructor for VGG implementation.

Parameters
  • x_tens – The input tensor to the VGG architecture

  • training – bool or Tensor to specify if the model should be run in training or inference mode

  • sec_settings – The settings for each section in the VGG modoel

  • num_classes – The number of classes to classify

  • class_type – One of [single, multi, None] to support multi class training. Default single. If None, then will not add the fully connected at the end.

  • kernel_initializer – Initializer to use for the conv and fully connected kernels

  • bias_initializer – Initializer to use for the bias in the fully connected

  • beta_initializer – Initializer to use for the batch norm beta variables

  • gamma_initializer – Initializer to use for the batch norm gama variables

Returns

the output tensor from the created graph

Module contents

Models related to image classification field in computer vision