Skip to content

Block

[source]

ConvBlock

autokeras.ConvBlock(
    kernel_size=None,
    num_blocks=None,
    num_layers=None,
    filters=None,
    max_pooling=None,
    separable=None,
    dropout=None,
    **kwargs
)

Block for vanilla ConvNets.

Arguments

  • kernel_size int | keras_tuner.src.engine.hyperparameters.hp_types.choice_hp.Choice | None: Int or keras_tuner.engine.hyperparameters.Choice. The size of the kernel. If left unspecified, it will be tuned automatically.
  • num_blocks int | keras_tuner.src.engine.hyperparameters.hp_types.choice_hp.Choice | None: Int or keras_tuner.engine.hyperparameters.Choice. The number of conv blocks, each of which may contain convolutional, max pooling, dropout, and activation. If left unspecified, it will be tuned automatically.
  • num_layers int | keras_tuner.src.engine.hyperparameters.hp_types.choice_hp.Choice | None: Int or hyperparameters.Choice. The number of convolutional layers in each block. If left unspecified, it will be tuned automatically.
  • filters int | keras_tuner.src.engine.hyperparameters.hp_types.choice_hp.Choice | None: Int or keras_tuner.engine.hyperparameters.Choice. The number of filters in the convolutional layers. If left unspecified, it will be tuned automatically.
  • max_pooling bool | None: Boolean. Whether to use max pooling layer in each block. If left unspecified, it will be tuned automatically.
  • separable bool | None: Boolean. Whether to use separable conv layers. If left unspecified, it will be tuned automatically.
  • dropout float | keras_tuner.src.engine.hyperparameters.hp_types.choice_hp.Choice | None: Float or kerastuner.engine.hyperparameters. Choice range Between 0 and 1. The dropout rate after convolutional layers. If left unspecified, it will be tuned automatically.

[source]

DenseBlock

autokeras.DenseBlock(num_layers=None, num_units=None, use_batchnorm=None, dropout=None, **kwargs)

Block for Dense layers.

Arguments

  • num_layers int | keras_tuner.src.engine.hyperparameters.hp_types.choice_hp.Choice | None: Int or keras_tuner.engine.hyperparameters.Choice. The number of Dense layers in the block. If left unspecified, it will be tuned automatically.
  • num_units int | keras_tuner.src.engine.hyperparameters.hp_types.choice_hp.Choice | None: Int or keras_tuner.engine.hyperparameters.Choice. The number of units in each dense layer. If left unspecified, it will be tuned automatically.
  • use_bn: Boolean. Whether to use BatchNormalization layers. If left unspecified, it will be tuned automatically.
  • dropout float | keras_tuner.src.engine.hyperparameters.hp_types.choice_hp.Choice | None: Float or keras_tuner.engine.hyperparameters.Choice. The dropout rate for the layers. If left unspecified, it will be tuned automatically.

[source]

Embedding

autokeras.Embedding(max_features=20001, embedding_dim=None, dropout=None, **kwargs)

Word embedding block for sequences.

The input should be tokenized sequences with the same length, where each element of a sequence should be the index of the word.

Arguments

  • max_features int: Int. Size of the vocabulary. Must be set if not using TextToIntSequence before this block. Defaults to 20001.
  • embedding_dim int | keras_tuner.src.engine.hyperparameters.hp_types.choice_hp.Choice | None: Int or keras_tuner.engine.hyperparameters.Choice. Output dimension of the Attention block. If left unspecified, it will be tuned automatically.
  • dropout float | keras_tuner.src.engine.hyperparameters.hp_types.choice_hp.Choice | None: Float or keras_tuner.engine.hyperparameters.Choice. The dropout rate for the layers. If left unspecified, it will be tuned automatically.

[source]

Merge

autokeras.Merge(merge_type=None, **kwargs)

Merge block to merge multiple nodes into one.

Arguments

  • merge_type str | None: String. 'add' or 'concatenate'. If left unspecified, it will be tuned automatically.

[source]

ResNetBlock

autokeras.ResNetBlock(version=None, pretrained=None, **kwargs)

Block for ResNet.

Arguments

  • version str | None: String. 'v1', 'v2'. The type of ResNet to use. If left unspecified, it will be tuned automatically.
  • pretrained bool | None: Boolean. Whether to use ImageNet pretrained weights. If left unspecified, it will be tuned automatically.

[source]

RNNBlock

autokeras.RNNBlock(
    return_sequences=False, bidirectional=None, num_layers=None, layer_type=None, **kwargs
)

An RNN Block.

Arguments

  • return_sequences bool: Boolean. Whether to return the last output in the output sequence, or the full sequence. Defaults to False.
  • bidirectional bool | keras_tuner.src.engine.hyperparameters.hp_types.boolean_hp.Boolean | None: Boolean or keras_tuner.engine.hyperparameters.Boolean. Bidirectional RNN. If left unspecified, it will be tuned automatically.
  • num_layers int | keras_tuner.src.engine.hyperparameters.hp_types.choice_hp.Choice | None: Int or keras_tuner.engine.hyperparameters.Choice. The number of layers in RNN. If left unspecified, it will be tuned automatically.
  • layer_type str | keras_tuner.src.engine.hyperparameters.hp_types.choice_hp.Choice | None: String or or keras_tuner.engine.hyperparameters.Choice. 'gru' or 'lstm'. If left unspecified, it will be tuned automatically.

[source]

SpatialReduction

autokeras.SpatialReduction(reduction_type=None, **kwargs)

Reduce the dimension of a spatial tensor, e.g. image, to a vector.

Arguments

  • reduction_type str | None: String. 'flatten', 'global_max' or 'global_avg'. If left unspecified, it will be tuned automatically.

[source]

TemporalReduction

autokeras.TemporalReduction(reduction_type=None, **kwargs)

Reduce the dim of a temporal tensor, e.g. output of RNN, to a vector.

Arguments

  • reduction_type str | None: String. 'flatten', 'global_max' or 'global_avg'. If left unspecified, it will be tuned automatically.

[source]

XceptionBlock

autokeras.XceptionBlock(pretrained=None, **kwargs)

Block for XceptionNet.

An Xception structure, used for specifying your model with specific datasets.

The original Xception architecture is from https://arxiv.org/abs/1610.02357. The data first goes through the entry flow, then through the middle flow which is repeated eight times, and finally through the exit flow.

This XceptionBlock returns a similar architecture as Xception except without the last (optional) fully connected layer(s) and logistic regression. The size of this architecture could be decided by HyperParameters, to get an architecture with a half, an identical, or a double size of the original one.

Arguments

  • pretrained bool | None: Boolean. Whether to use ImageNet pretrained weights. If left unspecified, it will be tuned automatically.

[source]

StructuredDataBlock

autokeras.StructuredDataBlock(normalize=None, **kwargs)

Block for structured data.

Arguments

  • categorical_encoding: Boolean. Whether to use the CategoricalToNumerical to encode the categorical features to numerical features. Defaults to True.
  • normalize bool | None: Boolean. Whether to normalize the features. If unspecified, it will be tuned automatically.

[source]

ImageBlock

autokeras.ImageBlock(block_type=None, normalize=None, augment=None, **kwargs)

Block for image data.

The image blocks is a block choosing from ResNetBlock, XceptionBlock, ConvBlock, which is controlled by a hyperparameter, 'block_type'.

Arguments

  • block_type str | None: String. 'resnet', 'xception', 'vanilla'. The type of Block to use. If unspecified, it will be tuned automatically.
  • normalize bool | None: Boolean. Whether to channel-wise normalize the images. If unspecified, it will be tuned automatically.
  • augment bool | None: Boolean. Whether to do image augmentation. If unspecified, it will be tuned automatically.

[source]

TextBlock

autokeras.TextBlock(max_tokens=None, **kwargs)

Block for text data.

Arguments

  • max_tokens: Int. The maximum size of the vocabulary. If left unspecified, it will be tuned automatically.

[source]

ImageAugmentation

autokeras.ImageAugmentation(
    translation_factor=None,
    vertical_flip=None,
    horizontal_flip=None,
    rotation_factor=None,
    zoom_factor=None,
    contrast_factor=None,
    **kwargs
)

Collection of various image augmentation methods.

Arguments

  • translation_factor float | Tuple[float, float] | keras_tuner.src.engine.hyperparameters.hp_types.choice_hp.Choice | None: A positive float represented as fraction value, or a tuple of 2 representing fraction for translation vertically and horizontally, or a kerastuner.engine.hyperparameters.Choice range of positive floats. For instance, translation_factor=0.2 result in a random translation factor within 20% of the width and height. If left unspecified, it will be tuned automatically.
  • vertical_flip bool | None: Boolean. Whether to flip the image vertically. If left unspecified, it will be tuned automatically.
  • horizontal_flip bool | None: Boolean. Whether to flip the image horizontally. If left unspecified, it will be tuned automatically.
  • rotation_factor float | keras_tuner.src.engine.hyperparameters.hp_types.choice_hp.Choice | None: Float or kerastuner.engine.hyperparameters.Choice range between [0, 1]. A positive float represented as fraction of 2pi upper bound for rotating clockwise and counter-clockwise. When represented as a single float, lower = upper. If left unspecified, it will be tuned automatically.
  • zoom_factor float | Tuple[float, float] | keras_tuner.src.engine.hyperparameters.hp_types.choice_hp.Choice | None: A positive float represented as fraction value, or a tuple of 2 representing fraction for zooming vertically and horizontally, or a kerastuner.engine.hyperparameters.Choice range of positive floats. For instance, zoom_factor=0.2 result in a random zoom factor from 80% to 120%. If left unspecified, it will be tuned automatically.
  • contrast_factor float | Tuple[float, float] | keras_tuner.src.engine.hyperparameters.hp_types.choice_hp.Choice | None: A positive float represented as fraction of value, or a tuple of size 2 representing lower and upper bound, or a kerastuner.engine.hyperparameters.Choice range of floats to find the optimal value. When represented as a single float, lower = upper. The contrast factor will be randomly picked between [1.0 - lower, 1.0 + upper]. If left unspecified, it will be tuned automatically.

[source]

Normalization

autokeras.Normalization(axis=-1, **kwargs)

Perform feature-wise normalization on data.

Refer to Normalization layer in keras preprocessing layers for more information.

Arguments

  • axis int: Integer or tuple of integers, the axis or axes that should be normalized (typically the features axis). We will normalize each element in the specified axis. The default is '-1' (the innermost axis); 0 (the batch axis) is not allowed.

[source]

ClassificationHead

autokeras.ClassificationHead(
    num_classes=None, multi_label=False, loss=None, metrics=None, dropout=None, **kwargs
)

Classification Dense layers.

Use sigmoid and binary crossentropy for binary classification and multi-label classification. Use softmax and categorical crossentropy for multi-class (more than 2) classification. Use Accuracy as metrics by default.

The targets passing to the head would have to be np.ndarray. It can be raw labels, one-hot encoded if more than two classes, or binary encoded for binary classification.

The raw labels will be encoded to one column if two classes were found, or one-hot encoded if more than two classes were found.

Arguments

  • num_classes int | None: Int. Defaults to None. If None, it will be inferred from the data.
  • multi_label bool: Boolean. Defaults to False.
  • loss str | Callable | keras.losses.Loss | None: A Keras loss function. Defaults to use binary_crossentropy or categorical_crossentropy based on the number of classes.
  • metrics List[str | Callable | keras.metrics.Metric] | List[List[str | Callable | keras.metrics.Metric]] | Dict[str, str | Callable | keras.metrics.Metric] | None: A list of Keras metrics. Defaults to use 'accuracy'.
  • dropout float | None: Float. The dropout rate for the layers. If left unspecified, it will be tuned automatically.

[source]

RegressionHead

autokeras.RegressionHead(
    output_dim=None, loss="mean_squared_error", metrics=None, dropout=None, **kwargs
)

Regression Dense layers.

The targets passing to the head would have to be np.ndarray. It can be single-column or multi-column. The values should all be numerical.

Arguments

  • output_dim int | None: Int. The number of output dimensions. Defaults to None. If None, it will be inferred from the data.
  • multi_label: Boolean. Defaults to False.
  • loss str | Callable | keras.losses.Loss: A Keras loss function. Defaults to use mean_squared_error.
  • metrics List[str | Callable | keras.metrics.Metric] | List[List[str | Callable | keras.metrics.Metric]] | Dict[str, str | Callable | keras.metrics.Metric] | None: A list of Keras metrics. Defaults to use mean_squared_error.
  • dropout float | None: Float. The dropout rate for the layers. If left unspecified, it will be tuned automatically.