paddlets.models.classify.dl.cnn

class CNNClassifier(loss_fn: ~typing.Callable[[...], ~paddle.Tensor] = <function cross_entropy>, optimizer_fn: ~typing.Callable[[...], ~paddle.optimizer.optimizer.Optimizer] = <class 'paddle.optimizer.adam.Adam'>, optimizer_params: ~typing.Dict[str, ~typing.Any] = {'learning_rate': 0.001}, eval_metrics: ~typing.List[str] = [], callbacks: ~typing.List[~paddlets.models.common.callbacks.callbacks.Callback] = [], batch_size: int = 32, max_epochs: int = 100, verbose: int = 1, patience: int = 10, seed: ~typing.Union[None, int] = None, activation: ~typing.Callable[[...], ~paddle.Tensor] = <class 'paddle.nn.layer.activation.Sigmoid'>, last_activation: ~typing.Callable[[...], ~paddle.Tensor] = <class 'paddle.nn.layer.activation.Softmax'>, use_bn: bool = False, hidden_config: ~typing.List[int] = [6, 12], kernel_size: int = 7, avg_pool_size=3, dropout_rate: float = 0.2, use_drop: bool = False)[source]

Bases: PaddleBaseClassifier

CNNClassifier.

Parameters
  • loss_fn (Callable[..., paddle.Tensor]) – Loss function.

  • optimizer_fn (Callable[..., Optimizer]) – Optimizer algorithm.

  • optimizer_params (Dict[str, Any]) – Optimizer parameters.

  • eval_metrics (List[str]) – Evaluation metrics of model.

  • callbacks (List[Callback]) – Customized callback functions.

  • batch_size (int) – Number of samples per batch.

  • max_epochs (int) – Max epochs during training.

  • verbose (int) – Verbosity mode.

  • patience (int) – Number of epochs to wait for improvement before terminating.

  • seed (int|None) – Global random seed.

  • activation (Callable[..., paddle.Tensor]) – The activation function for the hidden layers.

  • last_activation (Callable[..., paddle.Tensor]) – The activation function for the last hidden layers.

  • hidden_config (List[int]|None) – The ith element represents the number of neurons in the ith hidden layer.

  • kernel_size (int) – Kernel size for Conv1D.

  • dropout_rate (float) – Dropout regularization parameter.

  • use_bn (bool) – Whether to use batch normalization.

_loss_fn

Loss function.

Type

Callable[…, paddle.Tensor]

_optimizer_fn

Optimizer algorithm.

Type

Callable[…, Optimizer]

_optimizer_params

Optimizer parameters.

Type

Dict[str, Any]

_eval_metrics

Evaluation metrics of model.

Type

List[str]

_callbacks

Customized callback functions.

Type

List[Callback]

_batch_size

Number of samples per batch.

Type

int

_max_epochs

Max epochs during training.

Type

int

_verbose

Verbosity mode.

Type

int

_patience

Number of epochs to wait for improvement before terminating.

Type

int

_seed

Global random seed.

Type

int|None

_stop_training

Training status.

Type

bool

_activation

The activation function for the hidden layers.

Type

Callable[…, paddle.Tensor]

_last_activation

The activation function for the last hidden layers.

Type

Callable[…, paddle.Tensor]

_hidden_config

The ith element represents the number of neurons in the ith hidden layer.

Type

List[int]|None

_kernel_size

Kernel size for Conv1D.

Type

int

_dropout_rate

Dropout regularization parameter.

Type

float

_use_bn

Whether to use batch normalization.

Type

bool