estimators#
Note
See the Glossary for the meaning of the acronyms used in this guide.
keras_classifiers.py#
Neural network image classifiers implemented in Tensorflow/Keras.
- init_classifier(model_architecture: str, optimizer: tensorflow.keras.optimizers.Optimizer, metrics: List[Union[tensorflow.keras.metrics.Metric, function]], input_shape: Tuple[int, int, int], n_classes: int, loss: str = 'categorical_crossentropy') tensorflow.keras.models.Sequential [source]#
Initializes an untrained neural network image classifier for Tensorflow/Keras.
The model_architecture argument is used to select a neural network architecture from the architecture registry. The string passed to model_architecture must match one of the following,
“shallow_net” - A shallow neural network architecture.
“le_net” - The LeNet-5 convolutional neural network architecture.
“alex_net” - The AlexNet convolutional neural network architecture.
- Parameters
model_architecture – The neural network architecture to use.
optimizer – A Keras
Optimizer
providing an algorithm to use to train the estimator, such asSGD
andAdam
.metrics – A list of metrics to be evaluated by the model during training and testing.
input_shape – A shape tuple of integers, not including the batch size, specifying the dimensions of the image data. The shape tuple for all classifiers in the architecture registry follows the convention (height, width, channels).
n_classes – The number of target labels in the dataset.
loss – A string specifying the loss function to be minimized during training. The string must match the name of one of the loss functions in the
tf.keras.losses
module. The default is “categorical_crossentropy”.
- Returns
A compiled
Sequential
object.
See also
tf.keras.losses
tf.keras.optimizers
tf.keras.Sequential
- shallow_net(input_shape: Tuple[int, int, int], n_classes: int) tensorflow.keras.models.Sequential [source]#
Builds an untrained shallow neural network architecture for Tensorflow/Keras.
- Parameters
input_shape – A shape tuple of integers, not including the batch size, specifying the dimensions of the image data. The shape tuple for all classifiers in the architecture registry follows the convention (height, width, channels).
n_classes – The number of target labels in the dataset.
- Returns
A
Sequential
object.
See also
tf.keras.Sequential
- le_net(input_shape: Tuple[int, int, int], n_classes: int) tensorflow.keras.models.Sequential [source]#
Builds an untrained LeNet-5 neural network architecture for Tensorflow/Keras.
- Parameters
input_shape – A shape tuple of integers, not including the batch size, specifying the dimensions of the image data. The shape tuple for all classifiers in the architecture registry follows the convention (height, width, channels).
n_classes – The number of target labels in the dataset.
- Returns
A
Sequential
object.
See also
tf.keras.Sequential
- alex_net(input_shape: Tuple[int, int, int], n_classes: int) tensorflow.keras.models.Sequential [source]#
Builds an untrained AlexNet neural network architecture for Tensorflow/Keras.
- Parameters
input_shape – A shape tuple of integers, not including the batch size, specifying the dimensions of the image data. The shape tuple for all classifiers in the architecture registry follows the convention (height, width, channels).
n_classes – The number of target labels in the dataset.
- Returns
A
Sequential
object.
See also
tf.keras.Sequential
methods.py#
- fit(estimator: Any, x: Any = None, y: Any = None, fit_kwargs: Optional[Dict[str, Any]] = None) Any [source]#
Fits the estimator to the given data.
This task plugin wraps
fit_estimator()
, which is a generic function that uses multiple argument dispatch to handle the estimator fitting method for different machine learning libraries. The modules attached to the advertised plugin entry point dioptra.generics.fit_estimator are used to build the function dispatch registry at runtime. For more information on the supported fitting methods and fit_kwargs arguments, please refer to the documentation of the registered dispatch functions.- Parameters
estimator – The model to be trained.
x – The input data to be used for training.
y – The target data to be used for training.
fit_kwargs – An optional dictionary of keyword arguments to pass to the dispatched function.
- Returns
The object returned by the estimator’s fitting function. For further details on the type of object this method can return, see the documentation for the registered dispatch functions.
See also
- predict(estimator: Any, x: Any = None, predict_kwargs: Optional[Dict[str, Any]] = None) Any [source]#
Uses the estimator to make predictions on the given input data.
This task plugin wraps
estimator_predict()
, which is a generic function that uses multiple argument dispatch to handle estimator prediction methods for different machine learning libraries. The modules attached to the advertised plugin entry point dioptra.generics.estimator_predict are used to build the function dispatch registry at runtime. For more information on the supported prediction methods and predict_kwargs arguments, refer to the documentation of the registered dispatch functions.- Parameters
estimator – A trained model to be used to generate predictions.
x – The input data for which to generate predictions.
predict_kwargs – An optional dictionary of keyword arguments to pass to the dispatched function.
- Returns
The object returned by the estimator’s predict function. For further details on the type of object this method can return, see the documentation for the registered dispatch functions.