larq_zoo¶
BinaryAlexNet¶
BinaryAlexNet(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, classes=1000)
Optionally loads weights pretrained on ImageNet.
Interactive architecture diagram
Arguments
include_top
: whether to include the fullyconnected layer at the top of the network.weights
: one ofNone
(random initialization), "imagenet" (pretraining on ImageNet), or the path to the weights file to be loaded.input_tensor
: optional Keras tensor (i.e. output oflayers.Input()
) to use as image input for the model.input_shape
: optional shape tuple, only to be specified ifinclude_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 ifinclude_top
is True, and if noweights
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)
Optionally loads weights pretrained on ImageNet.
Interactive architecture diagram
Arguments
include_top
: whether to include the fullyconnected layer at the top of the network.weights
: one ofNone
(random initialization), "imagenet" (pretraining on ImageNet), or the path to the weights file to be loaded.input_tensor
: optional Keras tensor (i.e. output oflayers.Input()
) to use as image input for the model.input_shape
: optional shape tuple, only to be specified ifinclude_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 ifinclude_top
is True, and if noweights
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)
Optionally loads weights pretrained on ImageNet.
Interactive architecture diagram
Arguments
include_top
: whether to include the fullyconnected layer at the top of the network.weights
: one ofNone
(random initialization), "imagenet" (pretraining on ImageNet), or the path to the weights file to be loaded.input_tensor
: optional Keras tensor (i.e. output oflayers.Input()
) to use as image input for the model.input_shape
: optional shape tuple, only to be specified ifinclude_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 ifinclude_top
is True, and if noweights
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)
Optionally loads weights pretrained on ImageNet.
Interactive architecture diagram
Arguments
include_top
: whether to include the fullyconnected layer at the top of the network.weights
: one ofNone
(random initialization), "imagenet" (pretraining on ImageNet), or the path to the weights file to be loaded.input_tensor
: optional Keras tensor (i.e. output oflayers.Input()
) to use as image input for the model.input_shape
: optional shape tuple, only to be specified ifinclude_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 ifinclude_top
is True, and if noweights
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)
Optionally loads weights pretrained on ImageNet.
Interactive architecture diagram
Arguments
include_top
: whether to include the fullyconnected layer at the top of the network.weights
: one ofNone
(random initialization), "imagenet" (pretraining on ImageNet), or the path to the weights file to be loaded.input_tensor
: optional Keras tensor (i.e. output oflayers.Input()
) to use as image input for the model.input_shape
: optional shape tuple, only to be specified ifinclude_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 ifinclude_top
is True, and if noweights
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)
Optionally loads weights pretrained on ImageNet.
Interactive architecture diagram
Arguments
include_top
: whether to include the fullyconnected layer at the top of the network.weights
: one ofNone
(random initialization), "imagenet" (pretraining on ImageNet), or the path to the weights file to be loaded.input_tensor
: optional Keras tensor (i.e. output oflayers.Input()
) to use as image input for the model.input_shape
: optional shape tuple, only to be specified ifinclude_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 ifinclude_top
is True, and if noweights
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)
Optionally loads weights pretrained on ImageNet.
Interactive architecture diagram
Arguments
include_top
: whether to include the fullyconnected layer at the top of the network.weights
: one ofNone
(random initialization), "imagenet" (pretraining on ImageNet), or the path to the weights file to be loaded.input_tensor
: optional Keras tensor (i.e. output oflayers.Input()
) to use as image input for the model.input_shape
: optional shape tuple, only to be specified ifinclude_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 ifinclude_top
is True, and if noweights
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)
include_top
: whether to include the fullyconnected layer at the top of the network.weights
: one ofNone
(random initialization), "imagenet" (pretraining on ImageNet), or the path to the weights file to be loaded.input_tensor
: optional Keras tensor (i.e. output oflayers.Input()
) to use as image input for the model.input_shape
: optional shape tuple, only to be specified ifinclude_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 ifinclude_top
is True, and if noweights
argument is specified. Returns
A Keras model instance. Raises

ValueError: in case of invalid argument for
weights
, or invalid input shape. References 
DoReFaNet: Training Low Bitwidth Convolutional Neural Networks with Low Bitwidth Gradients
XNORNet¶
XNORNet(include_top=True, weights='imagenet', input_tensor=None, input_shape=None, classes=1000)
Optionally loads weights pretrained on ImageNet.
Interactive architecture diagram
Arguments
include_top
: whether to include the fullyconnected layer at the top of the network.weights
: one ofNone
(random initialization), "imagenet" (pretraining on ImageNet), or the path to the weights file to be loaded.input_tensor
: optional Keras tensor (i.e. output oflayers.Input()
) to use as image input for the model.input_shape
: optional shape tuple, only to be specified ifinclude_top
is False (otherwise the input shape has to be(224, 224, 3)
(withchannels_last
data format) or(3, 224, 224)
(withchannels_first
data format). It should have exactly 3 inputs channels.classes
: optional number of classes to classify images into, only to be specified ifinclude_top
is True, and if noweights
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)
Arguments
preds
: Numpy tensor encoding a batch of predictions.top
: Integer, how many topguesses 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)
Arguments
image
: Numpy array or symbolic Tensor, 3D.
Returns
Preprocessed Tensor or Numpy array.