Skip to content

Block

[source]

ConvBlock

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

Block for vanilla ConvNets.

Arguments

  • kernel_size Optional[int]: Int. If left unspecified, it will be tuned automatically.
  • num_blocks Optional[int]: Int. 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 Optional[int]: Int. The number of convolutional layers in each block. If left unspecified, it will be tuned automatically.
  • max_pooling Optional[bool]: Boolean. Whether to use max pooling layer in each block. If left unspecified, it will be tuned automatically.
  • separable Optional[bool]: Boolean. Whether to use separable conv layers. If left unspecified, it will be tuned automatically.
  • dropout Optional[float]: Float. Between 0 and 1. The dropout rate for after the convolutional layers. If left unspecified, it will be tuned automatically.

[source]

DenseBlock

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

Block for Dense layers.

Arguments

  • num_layers Optional[int]: Int. The number of Dense layers in the block. 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 Optional[float]: Float. The dropout rate for the layers. If left unspecified, it will be tuned automatically.

[source]

Embedding

autokeras.Embedding(max_features=20001, pretraining=None, 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.
  • pretraining Optional[str]: String. 'random' (use random weights instead any pretrained model), 'glove', 'fasttext' or 'word2vec'. Use pretrained word embedding. If left unspecified, it will be tuned automatically.
  • embedding_dim Optional[int]: Int. If left unspecified, it will be tuned automatically.
  • dropout Optional[float]: Float. The dropout rate for after the Embedding layer. 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 Optional[str]: 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 Optional[str]: String. 'v1', 'v2'. The type of ResNet to use. If left unspecified, it will be tuned automatically.
  • pretrained Optional[bool]: 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 Optional[bool]: Boolean. Bidirectional RNN. If left unspecified, it will be tuned automatically.
  • num_layers Optional[int]: Int. The number of layers in RNN. If left unspecified, it will be tuned automatically.
  • layer_type Optional[int]: String. '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 Optional[str]: 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 dimension of a temporal tensor, e.g. output of RNN, to a vector.

Arguments

  • reduction_type Optional[str]: 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 Optional[bool]: Boolean. Whether to use ImageNet pretrained weights. If left 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 Optional[str]: String. 'resnet', 'xception', 'vanilla'. The type of Block to use. If unspecified, it will be tuned automatically.
  • normalize Optional[bool]: Boolean. Whether to channel-wise normalize the images. If unspecified, it will be tuned automatically.
  • augment Optional[bool]: Boolean. Whether to do image augmentation. If unspecified, it will be tuned automatically.

[source]

StructuredDataBlock

autokeras.StructuredDataBlock(categorical_encoding=True, normalize=None, seed=None, **kwargs)

Block for structured data.

Arguments

  • categorical_encoding bool: Boolean. Whether to use the CategoricalToNumerical to encode the categorical features to numerical features. Defaults to True.
  • normalize Optional[bool]: Boolean. Whether to normalize the features. If unspecified, it will be tuned automatically.
  • seed Optional[int]: Int. Random seed.

[source]

TextBlock

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

Block for text data.

Arguments

  • block_type: String. 'vanilla', 'transformer', and 'ngram'. The type of Block to use. 'vanilla' and 'transformer' use a TextToIntSequence vectorizer, whereas 'ngram' uses TextToNgramVector. If unspecified, it will be tuned automatically.
  • max_tokens: Int. The maximum size of the vocabulary. If left unspecified, it will be tuned automatically.
  • pretraining: String. 'random' (use random weights instead any pretrained model), 'glove', 'fasttext' or 'word2vec'. Use pretrained word embedding. 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 Optional[Union[float, Tuple[float, float]]]: A positive float represented as fraction value, or a tuple of 2 representing fraction for translation vertically and horizontally. 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 Optional[bool]: Boolean. Whether to flip the image vertically. If left unspecified, it will be tuned automatically.
  • horizontal_flip Optional[bool]: Boolean. Whether to flip the image horizontally. If left unspecified, it will be tuned automatically.
  • rotation_factor Optional[float]: Float. 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 Optional[Union[float, Tuple[float, float]]]: A positive float represented as fraction value, or a tuple of 2 representing fraction for zooming vertically and horizontally. 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 Optional[Union[float, Tuple[float, float]]]: A positive float represented as fraction of value, or a tuple of size 2 representing lower and upper bound. 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 basic image transformation and augmentation.

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]

TextToIntSequence

autokeras.TextToIntSequence(output_sequence_length=None, max_tokens=20000, **kwargs)

Convert raw texts to sequences of word indices.

Arguments

  • output_sequence_length Optional[int]: Int. The maximum length of a sentence. If unspecified, it would be tuned automatically.
  • max_tokens int: Int. The maximum size of the vocabulary. Defaults to 20000.

[source]

TextToNgramVector

autokeras.TextToNgramVector(max_tokens=20000, ngrams=None, **kwargs)

Convert raw texts to n-gram vectors.

Arguments

  • max_tokens int: Int. The maximum size of the vocabulary. Defaults to 20000.
  • ngrams Optional[Union[int, Tuple[int]]]: Int or tuple of ints. Passing an integer will create ngrams up to that integer, and passing a tuple of integers will create ngrams for the specified values in the tuple. If left unspecified, it will be tuned automatically.

[source]

CategoricalToNumerical

autokeras.CategoricalToNumerical(**kwargs)

Encode the categorical features to numerical features.


[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 tf.data.Dataset, np.ndarray, pd.DataFrame or pd.Series. 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 Optional[int]: Int. Defaults to None. If None, it will be inferred from the data.
  • multi_label bool: Boolean. Defaults to False.
  • loss Optional[Union[str, Callable]]: A Keras loss function. Defaults to use binary_crossentropy or categorical_crossentropy based on the number of classes.
  • metrics Optional[Union[List[Union[str, Callable]], List[List[Union[str, Callable]]], Dict[str, Union[str, Callable]]]]: A list of Keras metrics. Defaults to use 'accuracy'.
  • dropout Optional[float]: 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 tf.data.Dataset, np.ndarray, pd.DataFrame or pd.Series. It can be single-column or multi-column. The values should all be numerical.

Arguments

  • output_dim Optional[int]: 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 Union[str, Callable]: A Keras loss function. Defaults to use mean_squared_error.
  • metrics Optional[Union[List[Union[str, Callable]], List[List[Union[str, Callable]]], Dict[str, Union[str, Callable]]]]: A list of Keras metrics. Defaults to use mean_squared_error.
  • dropout Optional[float]: Float. The dropout rate for the layers. If left unspecified, it will be tuned automatically.