Head

[source]

ClassificationHead class

autokeras.ClassificationHead(
    num_classes: Optional[int] = None,
    multi_label: bool = False,
    loss: Union[str, Callable, None] = None,
    metrics: Union[
        List[Union[str, Callable]], List[List[Union[str, Callable]]], Dict[str, Union[str, Callable]], None
    ] = None,
    dropout_rate: Optional[float] = 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: Int. Defaults to None. If None, it will be inferred 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.RegressionHead(
    output_dim: Optional[int] = None,
    loss: Union[str, Callable] = "mean_squared_error",
    metrics: Union[
        List[Union[str, Callable]], List[List[Union[str, Callable]]], Dict[str, Union[str, Callable]], None
    ] = None,
    dropout_rate: Optional[float] = 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: 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: 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.