Head

[source]

ClassificationHead class

autokeras.hypermodel.head.ClassificationHead(
    num_classes=None, multi_label=False, loss=None, metrics=None, dropout_rate=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. The targets can be raw labels, one-hot encoded for multi-class classification, or encoded to a single column 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. Defaults to None. If None, it will infer from the data.
  • multi_label: Boolean. Defaults to False.
  • loss: A Keras loss function. Defaults to use binary_crossentropy or categorical_crossentropy based on the number of classes.
  • metrics: A list of Keras metrics. Defaults to use 'accuracy'.
  • dropout_rate: Float. The dropout rate for the layers. If left unspecified, it will be tuned automatically.

[source]

RegressionHead class

autokeras.hypermodel.head.RegressionHead(
    output_dim=None, loss=None, metrics=None, dropout_rate=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.

Arguments

  • output_dim: Int. The number of output dimensions. Defaults to None. If None, it will infer from the data.
  • multi_label: Boolean. Defaults to False.
  • loss: A Keras loss function. Defaults to use mean_squared_error.
  • metrics: A list of Keras metrics. Defaults to use mean_squared_error.
  • dropout_rate: Float. The dropout rate for the layers. If left unspecified, it will be tuned automatically.