zoo.pipeline.api.keras package¶
Subpackages¶
- zoo.pipeline.api.keras.datasets package
- zoo.pipeline.api.keras.engine package
- zoo.pipeline.api.keras.layers package
- Submodules
- zoo.pipeline.api.keras.layers.advanced_activations module
- zoo.pipeline.api.keras.layers.convolutional module
- zoo.pipeline.api.keras.layers.convolutional_recurrent module
- zoo.pipeline.api.keras.layers.core module
- zoo.pipeline.api.keras.layers.embeddings module
- zoo.pipeline.api.keras.layers.local module
- zoo.pipeline.api.keras.layers.noise module
- zoo.pipeline.api.keras.layers.normalization module
- zoo.pipeline.api.keras.layers.pooling module
- zoo.pipeline.api.keras.layers.recurrent module
- zoo.pipeline.api.keras.layers.self_attention module
- zoo.pipeline.api.keras.layers.torch module
- zoo.pipeline.api.keras.layers.wrappers module
- Module contents
Submodules¶
zoo.pipeline.api.keras.base module¶
-
class
zoo.pipeline.api.keras.base.InferShape(bigdl_type='float')[source]¶ Bases:
bigdl.util.common.JavaValue
-
class
zoo.pipeline.api.keras.base.ZooKerasCreator(jvalue, bigdl_type, *args)[source]¶ Bases:
bigdl.util.common.JavaValue
-
class
zoo.pipeline.api.keras.base.ZooKerasLayer(jvalue, *args, **kwargs)[source]¶ Bases:
zoo.pipeline.api.keras.base.ZooKerasCreator,zoo.pipeline.api.keras.base.ZooCallable,bigdl.nn.layer.Layer,zoo.pipeline.api.keras.base.InferShape
zoo.pipeline.api.keras.metrics module¶
-
class
zoo.pipeline.api.keras.metrics.AUC(threshold_num=200, bigdl_type='float')[source]¶ Bases:
bigdl.util.common.JavaValueMetric for binary(0/1) classification, support single label and multiple labels.
# Arguments threshold_num: The number of thresholds. The quality of approximation
may vary depending on threshold_num.
>>> meter = AUC(20) creating: createAUC
-
class
zoo.pipeline.api.keras.metrics.Accuracy(zero_based_label=True, bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.base.ZooKerasCreator,bigdl.util.common.JavaValueMeasures top1 accuracy for multi-class classification or accuracy for binary classification.
# Arguments zero_based_label: Boolean. Whether target labels start from 0. Default is True.
If False, labels start from 1. Note that this only takes effect for multi-class classification. For binary classification, labels ought to be 0 or 1.
>>> acc = Accuracy() creating: createZooKerasAccuracy
-
class
zoo.pipeline.api.keras.metrics.BinaryAccuracy(bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.base.ZooKerasCreator,bigdl.util.common.JavaValueMeasures top1 accuracy for binary classification with zero-based index.
>>> acc = BinaryAccuracy() creating: createZooKerasBinaryAccuracy
-
class
zoo.pipeline.api.keras.metrics.CategoricalAccuracy(bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.base.ZooKerasCreator,bigdl.util.common.JavaValueMeasures top1 accuracy for multi-class classification when target is one-hot encoded.
>>> acc = CategoricalAccuracy() creating: createZooKerasCategoricalAccuracy
-
class
zoo.pipeline.api.keras.metrics.MAE(bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.base.ZooKerasCreator,bigdl.util.common.JavaValueMetric for mean absoluate error, similar from MAE criterion
>>> mae = MAE() creating: createZooKerasMAE
-
class
zoo.pipeline.api.keras.metrics.SparseCategoricalAccuracy(bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.base.ZooKerasCreator,bigdl.util.common.JavaValueMeasures top1 accuracy for multi-class classification with sparse target.
>>> acc = SparseCategoricalAccuracy() creating: createZooKerasSparseCategoricalAccuracy
-
class
zoo.pipeline.api.keras.metrics.Top5Accuracy(zero_based_label=True, bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.base.ZooKerasCreator,bigdl.util.common.JavaValueMeasures top5 accuracy for multi-class classification.
# Arguments zero_based_label: Boolean. Whether target labels start from 0. Default is True.
If False, labels start from 1.
>>> acc = Top5Accuracy() creating: createZooKerasTop5Accuracy
zoo.pipeline.api.keras.models module¶
-
class
zoo.pipeline.api.keras.models.Model(input, output, jvalue=None, **kwargs)[source]¶ Bases:
zoo.pipeline.api.keras.engine.topology.KerasNetContainer for a graph model.
# Arguments input: An input node or a list of input nodes. output: An output node or a list of output nodes. name: String to specify the name of the graph model. Default is None.
-
static
from_jvalue(jvalue, bigdl_type='float')[source]¶ Create a Python Model base on the given java value :param jvalue: Java object create by Py4j :return: A Python Model
-
static
-
class
zoo.pipeline.api.keras.models.Sequential(jvalue=None, **kwargs)[source]¶ Bases:
zoo.pipeline.api.keras.engine.topology.KerasNetContainer for a sequential model.
# Arguments name: String to specify the name of the sequential model. Default is None.
>>> sequential = Sequential(name="seq1") creating: createZooKerasSequential
zoo.pipeline.api.keras.objectives module¶
-
class
zoo.pipeline.api.keras.objectives.BinaryCrossEntropy(weights=None, size_average=True, bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.objectives.LossFunctionA loss that measures the Binary Cross Entropy between the target and the output
# Arguments size_average: Boolean. Whether losses are averaged over observations for each
mini-batch. Default is True. If False, the losses are instead summed for each mini-batch.
weights: weights over the input dimension
>>> loss = BinaryCrossEntropy() creating: createZooKerasBinaryCrossEntropy
-
class
zoo.pipeline.api.keras.objectives.CategoricalCrossEntropy(bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.objectives.LossFunctionThis is same with cross entropy criterion, except the target tensor is a one-hot tensor
>>> loss = CategoricalCrossEntropy() creating: createZooKerasCategoricalCrossEntropy
-
class
zoo.pipeline.api.keras.objectives.CosineProximity(bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.objectives.LossFunctionThe negative of the mean cosine proximity between predictions and targets. The cosine proximity is defined as below:
x’(i) = x(i) / sqrt(max(sum(x(i)^2), 1e-12)) y’(i) = y(i) / sqrt(max(sum(x(i)^2), 1e-12)) cosine_proximity(x, y) = mean(-1 * x’(i) * y’(i))
>>> loss = CosineProximity() creating: createZooKerasCosineProximity
-
class
zoo.pipeline.api.keras.objectives.Hinge(margin=1.0, size_average=True, bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.objectives.LossFunctionCreates a criterion that optimizes a two-class classification hinge loss (margin-based loss) between input x (a Tensor of dimension 1) and output y.
# Arguments: margin: Float. Default is 1.0. size_average: Boolean. Whether losses are averaged over observations for each
mini-batch. Default is True. If False, the losses are instead summed for each mini-batch.
>>> loss = Hinge() creating: createZooKerasHinge
-
class
zoo.pipeline.api.keras.objectives.KullbackLeiblerDivergence(bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.objectives.LossFunctionLoss calculated as:y_true = K.clip(y_true, K.epsilon(), 1) y_pred = K.clip(y_pred, K.epsilon(), 1) and output K.sum(y_true * K.log(y_true / y_pred), axis=-1)
>>> loss = KullbackLeiblerDivergence() creating: createZooKerasKullbackLeiblerDivergence
-
class
zoo.pipeline.api.keras.objectives.LossFunction(jvalue, bigdl_type, *args)[source]¶ Bases:
zoo.pipeline.api.keras.base.ZooKerasCreator,bigdl.nn.criterion.CriterionThe base class for Keras-style API objectives in Analytics Zoo.
-
zoo.pipeline.api.keras.objectives.MAE¶ alias of
zoo.pipeline.api.keras.objectives.MeanAbsoluteError
-
zoo.pipeline.api.keras.objectives.MAPE¶ alias of
zoo.pipeline.api.keras.objectives.MeanAbsolutePercentageError
-
zoo.pipeline.api.keras.objectives.MSE¶
-
zoo.pipeline.api.keras.objectives.MSLE¶ alias of
zoo.pipeline.api.keras.objectives.MeanSquaredLogarithmicError
-
class
zoo.pipeline.api.keras.objectives.MeanAbsoluteError(size_average=True, bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.objectives.LossFunctionA loss that measures the mean absolute value of the element-wise difference between the input and the target.
# Arguments size_average: Boolean. Whether losses are averaged over observations for each
mini-batch. Default is True. If False, the losses are instead summed for each mini-batch.
>>> loss = MeanAbsoluteError() creating: createZooKerasMeanAbsoluteError
-
class
zoo.pipeline.api.keras.objectives.MeanAbsolutePercentageError(bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.objectives.LossFunctionIt caculates diff = K.abs((y - x) / K.clip(K.abs(y), K.epsilon(), Double.MaxValue)) and return 100 * K.mean(diff) as outpout
>>> loss = MeanAbsolutePercentageError() creating: createZooKerasMeanAbsolutePercentageError
-
class
zoo.pipeline.api.keras.objectives.MeanSquaredError(size_average=True, bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.objectives.LossFunctionA loss that measures the mean squared value of the element-wise difference between the input and the target.
# Arguments size_average: Boolean. Whether losses are averaged over observations for each
mini-batch. Default is True. If False, the losses are instead summed for each mini-batch.
>>> loss = MeanSquaredError() creating: createZooKerasMeanSquaredError
-
class
zoo.pipeline.api.keras.objectives.MeanSquaredLogarithmicError(bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.objectives.LossFunctionIt calculates: first_log = K.log(K.clip(y, K.epsilon(), Double.MaxValue) + 1.) second_log = K.log(K.clip(x, K.epsilon(), Double.MaxValue) + 1.) and output K.mean(K.square(first_log - second_log))
>>> loss = MeanSquaredLogarithmicError() creating: createZooKerasMeanSquaredLogarithmicError
-
class
zoo.pipeline.api.keras.objectives.Poisson(bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.objectives.LossFunctionLoss calculated as: K.mean(y_pred - y_true * K.log(y_pred + K.epsilon()), axis=-1)
>>> loss = Poisson() creating: createZooKerasPoisson
-
class
zoo.pipeline.api.keras.objectives.RankHinge(margin=1.0, bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.objectives.LossFunctionHinge loss for pairwise ranking problems.
# Arguments: margin: Float. Default is 1.0.
>>> loss = RankHinge() creating: createZooKerasRankHinge
-
class
zoo.pipeline.api.keras.objectives.SparseCategoricalCrossEntropy(log_prob_as_input=False, zero_based_label=True, weights=None, size_average=True, padding_value=-1, bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.objectives.LossFunctionA loss often used in multi-class classification problems with SoftMax as the last layer of the neural network.
By default, same as Keras, input(y_pred) is supposed to be probabilities of each class, and target(y_true) is supposed to be the class label starting from 0.
# Arguments log_prob_as_input: Boolean. Whether to accept log-probabilities or probabilities
as input. Default is False and inputs should be probabilities.
- zero_based_label: Boolean. Whether target labels start from 0. Default is True.
If False, labels start from 1.
weights: A Numpy array. Weights of each class if you have an unbalanced training set. size_average: Boolean. Whether losses are averaged over observations for each
mini-batch. Default is True. If False, the losses are instead summed for each mini-batch.
- padding_value: Int. If the target is set to this value, the training process
will skip this sample. In other words, the forward process will return zero output and the backward process will also return zero grad_input. Default is -1.
>>> loss = SparseCategoricalCrossEntropy() creating: createZooKerasSparseCategoricalCrossEntropy >>> import numpy as np >>> np.random.seed(1128) >>> weights = np.random.uniform(0, 1, (2,)).astype("float32") >>> loss = SparseCategoricalCrossEntropy(weights=weights) creating: createZooKerasSparseCategoricalCrossEntropy
-
class
zoo.pipeline.api.keras.objectives.SquaredHinge(margin=1.0, size_average=False, bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.objectives.LossFunctionCreates a criterion that optimizes a two-class classification squared hinge loss (margin-based loss) between input x (a Tensor of dimension 1) and output y.
# Arguments: margin: Float. Default is 1.0. size_average: Boolean. Whether losses are averaged over observations for each
mini-batch. Default is True. If False, the losses are instead summed for each mini-batch.
>>> loss = SquaredHinge() creating: createZooKerasSquaredHinge
-
zoo.pipeline.api.keras.objectives.mae¶ alias of
zoo.pipeline.api.keras.objectives.MeanAbsoluteError
-
zoo.pipeline.api.keras.objectives.mape¶ alias of
zoo.pipeline.api.keras.objectives.MeanAbsolutePercentageError
-
zoo.pipeline.api.keras.objectives.mse¶
-
zoo.pipeline.api.keras.objectives.msle¶ alias of
zoo.pipeline.api.keras.objectives.MeanSquaredLogarithmicError
zoo.pipeline.api.keras.optimizers module¶
-
class
zoo.pipeline.api.keras.optimizers.Adam(lr=0.001, beta_1=0.9, beta_2=0.999, epsilon=1e-08, decay=0.0, schedule=None, weight_decay=0.0, bigdl_type='float')[source]¶ Bases:
bigdl.optim.optimizer.OptimMethod,zoo.pipeline.api.keras.base.ZooKerasCreatorAn implementation of Adam with learning rate schedule. >>> adam = Adam() creating: createZooKerasAdam creating: createDefault
-
class
zoo.pipeline.api.keras.optimizers.AdamWeightDecay(lr=0.001, warmup_portion=-1.0, total=-1, schedule='linear', beta1=0.9, beta2=0.999, epsilon=1e-06, weight_decay=0.01, bigdl_type='float')[source]¶ Bases:
bigdl.optim.optimizer.OptimMethod,zoo.pipeline.api.keras.base.ZooKerasCreatorImplements BERT version of Adam algorithm. >>> adam = AdamWeightDecay() creating: createZooKerasAdamWeightDecay
-
class
zoo.pipeline.api.keras.optimizers.PolyEpochDecay(power, max_epochs, bigdl_type='float')[source]¶ Bases:
zoo.pipeline.api.keras.base.ZooKerasCreatorA learning rate decay policy, where the effective learning rate follows a polynomial decay, to be zero by the max_epochs. Calculation: init_lr * (1 - epoch/max_iteration) ^ (power)
- Parameters
power – The coefficient of decay.
max_epochs – The maximum number of epochs when lr becomes zero.
>>> poly = PolyEpochDecay(0.5, 5) creating: createZooKerasPolyEpochDecay