# larq_zoo¶

## BinaryAlexNet¶

BinaryAlexNet(include_top=True,
weights='imagenet',
input_tensor=None,
input_shape=None,
classes=1000)

Instantiates the BinaryAlexNet architecture.

Optionally loads weights pre-trained on ImageNet.

Arguments

• include_top: whether to include the fully-connected layer at the top of the network.
• weights: one of None (random initialization), "imagenet" (pre-training on ImageNet), or the path to the weights file to be loaded.
• input_tensor: optional Keras tensor (i.e. output of layers.Input()) to use as image input for the model.
• input_shape: optional shape tuple, only to be specified if include_top is False, otherwise the input shape has to be (224, 224, 3). It should have exactly 3 inputs channels.
• classes: optional number of classes to classify images into, only to be specified if include_top is True, and if no weights argument is specified.

Returns

A Keras model instance.

Raises

• ValueError: in case of invalid argument for weights, or invalid input shape.

## BiRealNet¶

BiRealNet(include_top=True,
weights='imagenet',
input_tensor=None,
input_shape=None,
classes=1000)

Instantiates the Bi-Real Net architecture.

Optionally loads weights pre-trained on ImageNet.

Arguments

• include_top: whether to include the fully-connected layer at the top of the network.
• weights: one of None (random initialization), "imagenet" (pre-training on ImageNet), or the path to the weights file to be loaded.
• input_tensor: optional Keras tensor (i.e. output of layers.Input()) to use as image input for the model.
• input_shape: optional shape tuple, only to be specified if include_top is False, otherwise the input shape has to be (224, 224, 3). It should have exactly 3 inputs channels.
• classes: optional number of classes to classify images into, only to be specified if include_top is True, and if no weights argument is specified.

Returns

A Keras model instance.

Raises

• ValueError: in case of invalid argument for weights, or invalid input shape.

References

## BinaryResNetE18¶

BinaryResNetE18(include_top=True,
weights='imagenet',
input_tensor=None,
input_shape=None,
classes=1000)

Instantiates the BinaryResNetE 18 architecture.

Optionally loads weights pre-trained on ImageNet.

Arguments

• include_top: whether to include the fully-connected layer at the top of the network.
• weights: one of None (random initialization), "imagenet" (pre-training on ImageNet), or the path to the weights file to be loaded.
• input_tensor: optional Keras tensor (i.e. output of layers.Input()) to use as image input for the model.
• input_shape: optional shape tuple, only to be specified if include_top is False, otherwise the input shape has to be (224, 224, 3). It should have exactly 3 inputs channels.
• classes: optional number of classes to classify images into, only to be specified if include_top is True, and if no weights argument is specified.

Returns

A Keras model instance.

Raises

• ValueError: in case of invalid argument for weights, or invalid input shape.

References

## BinaryDenseNet28¶

BinaryDenseNet28(include_top=True,
weights='imagenet',
input_tensor=None,
input_shape=None,
classes=1000)

Instantiates the BinaryDenseNet 28 architecture.

Optionally loads weights pre-trained on ImageNet.

Arguments

• include_top: whether to include the fully-connected layer at the top of the network.
• weights: one of None (random initialization), "imagenet" (pre-training on ImageNet), or the path to the weights file to be loaded.
• input_tensor: optional Keras tensor (i.e. output of layers.Input()) to use as image input for the model.
• input_shape: optional shape tuple, only to be specified if include_top is False, otherwise the input shape has to be (224, 224, 3). It should have exactly 3 inputs channels.
• classes: optional number of classes to classify images into, only to be specified if include_top is True, and if no weights argument is specified.

Returns

A Keras model instance.

Raises

• ValueError: in case of invalid argument for weights, or invalid input shape.

References

## BinaryDenseNet37¶

BinaryDenseNet37(include_top=True,
weights='imagenet',
input_tensor=None,
input_shape=None,
classes=1000)

Instantiates the BinaryDenseNet 37 architecture.

Optionally loads weights pre-trained on ImageNet.

Arguments

• include_top: whether to include the fully-connected layer at the top of the network.
• weights: one of None (random initialization), "imagenet" (pre-training on ImageNet), or the path to the weights file to be loaded.
• input_tensor: optional Keras tensor (i.e. output of layers.Input()) to use as image input for the model.
• input_shape: optional shape tuple, only to be specified if include_top is False, otherwise the input shape has to be (224, 224, 3). It should have exactly 3 inputs channels.
• classes: optional number of classes to classify images into, only to be specified if include_top is True, and if no weights argument is specified.

Returns

A Keras model instance.

Raises

• ValueError: in case of invalid argument for weights, or invalid input shape.

References

## BinaryDenseNet37Dilated¶

BinaryDenseNet37Dilated(include_top=True,
weights='imagenet',
input_tensor=None,
input_shape=None,
classes=1000)

Instantiates the Dilated BinaryDenseNet 37 architecture.

Optionally loads weights pre-trained on ImageNet.

Arguments

• include_top: whether to include the fully-connected layer at the top of the network.
• weights: one of None (random initialization), "imagenet" (pre-training on ImageNet), or the path to the weights file to be loaded.
• input_tensor: optional Keras tensor (i.e. output of layers.Input()) to use as image input for the model.
• input_shape: optional shape tuple, only to be specified if include_top is False, otherwise the input shape has to be (224, 224, 3). It should have exactly 3 inputs channels.
• classes: optional number of classes to classify images into, only to be specified if include_top is True, and if no weights argument is specified.

Returns

A Keras model instance.

Raises

• ValueError: in case of invalid argument for weights, or invalid input shape.

References

## BinaryDenseNet45¶

BinaryDenseNet45(include_top=True,
weights='imagenet',
input_tensor=None,
input_shape=None,
classes=1000)

Instantiates the Binary BinaryDenseNet 45 architecture.

Optionally loads weights pre-trained on ImageNet.

Arguments

• include_top: whether to include the fully-connected layer at the top of the network.
• weights: one of None (random initialization), "imagenet" (pre-training on ImageNet), or the path to the weights file to be loaded.
• input_tensor: optional Keras tensor (i.e. output of layers.Input()) to use as image input for the model.
• input_shape: optional shape tuple, only to be specified if include_top is False, otherwise the input shape has to be (224, 224, 3). It should have exactly 3 inputs channels.
• classes: optional number of classes to classify images into, only to be specified if include_top is True, and if no weights argument is specified.

Returns

A Keras model instance.

Raises

• ValueError: in case of invalid argument for weights, or invalid input shape.

References

## DoReFaNet¶

DoReFaNet(include_top=True,
weights='imagenet',
input_tensor=None,
input_shape=None,
classes=1000)

Instantiates the DoReFa-net architecture. Optionally loads weights pre-trained on ImageNet. Interactive architecture diagram
Arguments

• include_top: whether to include the fully-connected layer at the top of the network.
• weights: one of None (random initialization), "imagenet" (pre-training on ImageNet), or the path to the weights file to be loaded.
• input_tensor: optional Keras tensor (i.e. output of layers.Input()) to use as image input for the model.
• input_shape: optional shape tuple, only to be specified if include_top is False, otherwise the input shape has to be (224, 224, 3). It should have exactly 3 inputs channels.
• classes: optional number of classes to classify images into, only to be specified if include_top is True, and if no weights argument is specified. Returns

A Keras model instance. Raises

## XNORNet¶

XNORNet(include_top=True,
weights='imagenet',
input_tensor=None,
input_shape=None,
classes=1000)

Instantiates the XNOR-Net architecture.

Optionally loads weights pre-trained on ImageNet.

Arguments

• include_top: whether to include the fully-connected layer at the top of the network.
• weights: one of None (random initialization), "imagenet" (pre-training on ImageNet), or the path to the weights file to be loaded.
• input_tensor: optional Keras tensor (i.e. output of layers.Input()) to use as image input for the model.
• input_shape: optional shape tuple, only to be specified if include_top is False (otherwise the input shape has to be (224, 224, 3) (with channels_last data format) or (3, 224, 224) (with channels_first data format). It should have exactly 3 inputs channels.
• classes: optional number of classes to classify images into, only to be specified if include_top is True, and if no weights argument is specified.

Returns

A Keras model instance.

Raises

• ValueError: in case of invalid argument for weights, or invalid input shape.

References

## decode_predictions¶

decode_predictions(preds, top=5, **kwargs)

Decodes the prediction of an ImageNet model.

Arguments

• preds: Numpy tensor encoding a batch of predictions.
• top: Integer, how many top-guesses to return.

Returns

A list of lists of top class prediction tuples (class_name, class_description, score). One list of tuples per sample in batch input.

Raises

• ValueError: In case of invalid shape of the pred array (must be 2D).

## preprocess_input¶

preprocess_input(image)

Preprocesses a Tensor or Numpy array encoding a image.

Arguments

• image: Numpy array or symbolic Tensor, 3D.

Returns

Preprocessed Tensor or Numpy array.