autoqild.classifiers.layers

A custom dense layer with batch normalization and optional pre-activation normalization.

Classes

NormalizedDense(*args, **kwargs)

A custom dense layer with batch normalization and optional pre- activation normalization.

class autoqild.classifiers.layers.NormalizedDense(*args, **kwargs)[source]

Bases: Layer

A custom dense layer with batch normalization and optional pre- activation normalization.

Parameters:
  • units (int) – Positive integer, dimensionality of the output space.

  • activation (str, optional) – Activation function to use (default is relu). If not specified, no activation is applied (i.e., “linear”).

  • normalize_before_activation (bool, optional) – If True, normalizes the inputs before applying the activation function. If False, applies activation before batch normalization.

  • **kwd (dict) – Additional keyword arguments to pass to the Dense layer.

dense

Dense layer instance.

Type:

keras.layers.Dense

activation

Activation function to be applied.

Type:

keras.layers.Activation

batchnorm

Batch normalization layer.

Type:

keras.layers.BatchNormalization

norm_layer

Normalization layer if specified.

Type:

keras.layers.Layer or None

__call__(x)[source]
get_weights()[source]

Returns the weights of the batch normalization and dense layers.

Returns:

  • w_b (tensor) – Weights of the batch normalization layers.

  • w_d (tensor) – Weights of the dense layers.

set_weights(weights)[source]

Sets the weights of the batch normalization and dense layers.

Parameters:

weights (tuple, (tensor, tensor)) – A tuple containing the weights for the batch normalization and dense layers.