Skip to content

create_dl_layer_activationCreateDlLayerActivationCreateDlLayerActivationcreate_dl_layer_activationT_create_dl_layer_activation🔗

Short description🔗

create_dl_layer_activationCreateDlLayerActivationCreateDlLayerActivationcreate_dl_layer_activationT_create_dl_layer_activation — Create an activation layer.

Signature🔗

create_dl_layer_activation( dl_layer DLLayerInput, string LayerName, string ActivationType, attribute.name GenParamName, attribute.value GenParamValue, out dl_layer DLLayerActivation )void CreateDlLayerActivation( const HTuple& DLLayerInput, const HTuple& LayerName, const HTuple& ActivationType, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DLLayerActivation )static void HOperatorSet.CreateDlLayerActivation( HTuple DLLayerInput, HTuple layerName, HTuple activationType, HTuple genParamName, HTuple genParamValue, out HTuple DLLayerActivation )def create_dl_layer_activation( dllayer_input: HHandle, layer_name: str, activation_type: str, gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]] ) -> HHandle

Herror T_create_dl_layer_activation( const Htuple DLLayerInput, const Htuple LayerName, const Htuple ActivationType, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DLLayerActivation )

HDlLayer HDlLayer::CreateDlLayerActivation( const HString& LayerName, const HString& ActivationType, const HTuple& GenParamName, const HTuple& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerActivation( const HString& LayerName, const HString& ActivationType, const HString& GenParamName, const HString& GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerActivation( const char* LayerName, const char* ActivationType, const char* GenParamName, const char* GenParamValue ) const

HDlLayer HDlLayer::CreateDlLayerActivation( const wchar_t* LayerName, const wchar_t* ActivationType, const wchar_t* GenParamName, const wchar_t* GenParamValue ) const (Windows only)

HDlLayer HDlLayer.CreateDlLayerActivation( string layerName, string activationType, HTuple genParamName, HTuple genParamValue )

HDlLayer HDlLayer.CreateDlLayerActivation( string layerName, string activationType, string genParamName, string genParamValue )

Description🔗

The operator create_dl_layer_activationCreateDlLayerActivation creates an activation layer whose handle is returned in DLLayerActivationDLLayerActivationdllayer_activation.

The parameter DLLayerInputDLLayerInputdllayer_input determines the feeding input layer and expects the layer handle as value.

The parameter LayerNamelayerNamelayer_name sets an individual layer name. Note that if creating a model using create_dl_modelCreateDlModel each layer of the created network must have a unique name.

The parameter ActivationTypeactivationTypeactivation_type sets the type of the activation. Every activation mode defines a pointwise function. Supported activation types are:

  • 'abs'"abs": Absolute value.

    \[\begin{eqnarray*} Abs(x) := |x| \end{eqnarray*}\]
  • 'acos'"acos": Arccosine activation.

  • 'asin'"asin": Arcsine activation.

  • 'atan'"atan": Arctangent activation.

  • 'ceil'"ceil": Rounds the input up to the nearest integer.

  • 'celu'"celu": Continuously differentiable exponential linear unit (Celu) activation, which is defined as follows:

    \[\begin{eqnarray*} Celu(x) := \left\{\begin{array}{ll} \alpha (e^{\frac{x}{\alpha}} - 1) & \textnormal{if } x < 0, \\ x & \textnormal{else.} \end{array} \right. \end{eqnarray*}\]

    Setting the generic parameter 'alpha'"alpha" determines the value \(\alpha\) (default: 1.0). For \(\alpha=1\) a Celu activation is identical to an ELU.

  • 'clip'"clip": Clip the input to a given interval:

    \[\begin{eqnarray*} Clip(x) := \left\{\begin{array}{ll} min & \textnormal{if } x\leq min, \\ max & \textnormal{if } x\geq max,\\ x & \textnormal{else.} \end{array} \right. \end{eqnarray*}\]

    Setting the generic parameters 'min'"min" and 'max'"max" determines the values \(min\) and \(max\), respectively.

  • 'cos'"cos": Cosine activation.

  • 'cosh'"cosh": Hyperbolic cosine activation.

  • 'elu'"elu": Exponential linear unit (ELU) activation, which is defined as follows:

    \[\begin{eqnarray*} ELU(x) := \left\{\begin{array}{ll} \alpha (e^x - 1) & \textnormal{if } x < 0, \\ x & \textnormal{else.} \end{array} \right. \end{eqnarray*}\]

    Setting the generic parameter 'alpha'"alpha" determines the value \(\alpha\) (default: 1.0).

  • 'erf'"erf": Gauss error function, which is defined as follows:

    \[\begin{eqnarray*} erf(x) := \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^2} \,dt \end{eqnarray*}\]
  • 'exp'"exp": Exponential function:

    \[\begin{eqnarray*} Exp(x) := e^x \end{eqnarray*}\]
  • 'floor'"floor": Rounds the input down to the nearest integer.

  • 'gelu'"gelu": Gaussian error linear unit (Gelu) activation, which is defined as follows:

    \[\begin{eqnarray*} Gelu(x) := 0.5 * x * (1 + erf(\frac{x}{\sqrt{2}})) \end{eqnarray*}\]

    Setting the generic parameter 'approximate'"approximate" to 'tanh'"tanh" determines whether an approximate function estimation is used:

    \[\begin{eqnarray*} Gelu(x) := 0.5 * x * (1 + tanh(\sqrt{\frac{2}{\pi}} * (x + 0.044715 * x^3))) \end{eqnarray*}\]
  • 'hard_sigmoid'"hard_sigmoid": HardSigmoid activation:

    \[\begin{eqnarray*} HardSigmoid(x) := \max(0, \min(1, \alpha x + \beta)) \end{eqnarray*}\]

    Setting the generic parameters 'alpha'"alpha" and 'beta'"beta" determines the values \(\alpha\) (default: 0.2) and \(\beta\) (default: 0.5).

  • 'hard_swish'"hard_swish": HardSwish activation:

    \[\begin{eqnarray*} HardSwish(x) := x * HardSigmoid(x) \end{eqnarray*}\]

    with fixed \(\alpha=\frac{1}{6}\) and \(\beta=0.5\).

  • 'log'"log": Natural logarithm:

    \[\begin{eqnarray*} Log(x) := \log(x) \end{eqnarray*}\]
  • 'mish'"mish": Mish activation:

    \[\begin{eqnarray*} Mish(x) := x * \tanh{(Softplus(x))} \end{eqnarray*}\]
  • 'neg'"neg": Negative of input:

    \[\begin{eqnarray*} Neg(x) := -x \end{eqnarray*}\]
  • 'pow'"pow": Power function:

    \[\begin{eqnarray*} Pow(x) := x^{exponent} \end{eqnarray*}\]

    Setting the generic parameter 'exponent'"exponent" determines the value \(exponent\).

  • 'reciprocal'"reciprocal": Reciprocal function:

    \[\begin{eqnarray*} Reciprocal(x) := \frac{1}{x} \end{eqnarray*}\]
  • 'relu'"relu": Rectified linear unit (ReLU) activation. By setting a specific ReLU parameter, another type can be specified instead of the standard ReLU:

    • Standard ReLU, defined as follows:

      \[\begin{eqnarray*} ReLU(x) := \max(0, x) \end{eqnarray*}\]
    • Bounded ReLU, defined as follows:

      \[\begin{eqnarray*} ReLU(x) := \left\{\begin{array}{ll} 0 & \textnormal{if } x\leq 0, \\ x & \textnormal{if } 0<x\leq\beta,\\ \beta & \textnormal{else.} \end{array} \right. \end{eqnarray*}\]

      Setting the generic parameter 'upper_bound'"upper_bound" will result in a bounded ReLU and determines the value of \(\beta\).

    • Leaky ReLU, defined as follows:

      \[\begin{eqnarray*} ReLU(x) := \left\{\begin{array}{ll} \alpha x & \textnormal{if } x\leq 0, \\ x & \textnormal{else.} \end{array} \right. \end{eqnarray*}\]

      Setting the generic parameter 'alpha'"alpha" results in a leaky ReLU and determines the value \(\alpha\). When the generic parameter 'upper_bound'"upper_bound" is set, 'alpha'"alpha" will be ignored and the result will be a bounded ReLU.

  • 'round'"round": Rounds the input to the nearest integer. Values with ‘.5’ are rounded to the nearest even integer, e.g.: \(Round(2.5) = 2\), \(Round(3.5) = 4\).

  • 'sigmoid'"sigmoid": Sigmoid activation, which is defined as follows:

    \[\begin{eqnarray*} Sigmoid(x) := \frac{1}{1 + e^{-x}} \end{eqnarray*}\]
  • 'sin'"sin": Sine activation.

  • 'sinh'"sinh": Hyperbolic sine activation.

  • 'softplus'"softplus": Softplus activation function, which is defined as follows:

    \[\begin{eqnarray*} Softplus(x) := \log(e^{x} + 1) \end{eqnarray*}\]
  • 'softsign'"softsign": Softsign activation function, which is defined as follows:

    \[\begin{eqnarray*} Softsign(x) := \frac{x}{1 + |x|} \end{eqnarray*}\]
  • 'sqrt'"sqrt": Square root of the input:

    \[\begin{eqnarray*} Sqrt(x) := \sqrt{x} \end{eqnarray*}\]
  • 'swish'"swish": Swish activation function, which is defined as follows:

    \[\begin{eqnarray*} Swish(x) := x * sigmoid(\alpha x) = \frac{x}{1 + e^{-\alpha x}} \end{eqnarray*}\]

    Setting the generic parameter 'alpha'"alpha" determines the value \(\alpha\) (default: 1.0).

  • 'tan'"tan": Tangent activation.

  • 'tanh'"tanh": Tanh activation, which is defined as follows:

    \[\begin{eqnarray*} Tanh(x) := 1 - \frac{2}{e^{2x} + 1} \end{eqnarray*}\]
  • 'thresholded_relu'"thresholded_relu": Thresholded ReLU, defined as follows:

    \[\begin{eqnarray*} ThresholdedReLU(x) := \left\{\begin{array}{ll} 0 & \textnormal{if } x\leq \alpha, \\ x & \textnormal{else.} \end{array} \right. \end{eqnarray*}\]

    Setting the generic parameter 'alpha'"alpha" determines the value \(\alpha\) (default: 1.0).

The following generic parameters GenParamNamegenParamNamegen_param_name and the corresponding values GenParamValuegenParamValuegen_param_value are supported:

  • 'is_inference_output'"is_inference_output": Determines whether apply_dl_modelApplyDlModel will include the output of this layer in the dictionary DLResultBatchDLResultBatchdlresult_batch even without specifying this layer in Outputsoutputsoutputs ('true'"true") or not ('false'"false").

    Default: 'false'"false"

  • 'upper_bound'"upper_bound" ('relu'"relu"): Float value defining an upper bound for a rectified linear unit. If the activation layer is part of a model which has been created using create_dl_modelCreateDlModel, the upper bound can be unset. To do so, use set_dl_model_layer_paramSetDlModelLayerParam and set an empty tuple for 'upper_bound'"upper_bound".

    Default: [][]

  • 'alpha'"alpha" ('relu'"relu", 'elu'"elu", 'celu'"celu",'thresholded_relu'"thresholded_relu", 'swish'"swish", 'hard_sigmoid'"hard_sigmoid"): Float value defining the alpha parameter of a leaky ReLU, thresholded ReLU, ELU, CELU, Swish or HardSigmoid-activation.

    Restriction: The value of 'alpha'"alpha" must be positive or zero for all activations except for ActivationTypeactivationTypeactivation_type 'thresholded_relu'"thresholded_relu". This parameter is incompatible with and overridden by 'upper_bound'"upper_bound" for ActivationTypeactivationTypeactivation_type 'relu'"relu".

    Default: 0.20.2 for 'hard_sigmoid'"hard_sigmoid", else 1.01.0

  • 'beta'"beta" ('hard_sigmoid'"hard_sigmoid"): Float value defining the beta parameter of a HardSigmoid activation.

    Default: 0.50.5

  • 'min'"min" ('clip'"clip"): Float value defining the min parameter of a clip activation.

  • 'max'"max" ('clip'"clip"): Float value defining the max parameter of a clip activation.

  • 'approximate'"approximate" ('gelu'"gelu"): This value determines whether an approximate function estimation is used.

    List of values: 'tanh'"tanh", 'false'"false"

    Default: 'false'"false"

  • 'exponent'"exponent" ('pow'"pow"): Float value defining the exponent parameter of a pow activation.

Certain parameters of layers created using this operator create_dl_layer_activationCreateDlLayerActivation can be set and retrieved using further operators. The following tables give an overview, which parameters can be set using set_dl_model_layer_paramSetDlModelLayerParam and which ones can be retrieved using get_dl_model_layer_paramGetDlModelLayerParam or get_dl_layer_paramGetDlLayerParam. Note, the operators set_dl_model_layer_paramSetDlModelLayerParam and get_dl_model_layer_paramGetDlModelLayerParam require a model created by create_dl_modelCreateDlModel.

Layer Parameters set get
'activation_type'"activation_type" (ActivationTypeactivationTypeactivation_type) x x
'input_layer'"input_layer" (DLLayerInputDLLayerInputdllayer_input) x
'name'"name" (LayerNamelayerNamelayer_name) x x
'output_layer'"output_layer" (DLLayerActivationDLLayerActivationdllayer_activation) x
'shape'"shape" x
'type'"type" x
Generic Layer Parameters set get
'is_inference_output'"is_inference_output" x x
'num_trainable_params'"num_trainable_params" x
'alpha'"alpha" x x
'beta'"beta" x x
'upper_bound'"upper_bound" x x
'min'"min" x x
'max'"max" x x
'approximate'"approximate" x x
'exponent'"exponent" x x

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

DLLayerInputDLLayerInputdllayer_input (input_control) dl_layer → (handle)HTuple (HHandle)HDlLayer, HTuple (IntPtr)HHandleHtuple (handle)

Feeding layer.

LayerNamelayerNamelayer_name (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Name of the output layer.

ActivationTypeactivationTypeactivation_type (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Activation type.

Default: 'relu'"relu"
List of values: 'abs', 'acos', 'asin', 'atan', 'ceil', 'celu', 'clip', 'cos', 'cosh', 'elu', 'erf', 'exp', 'floor', 'gelu', 'hard_sigmoid', 'hard_swish', 'log', 'mish', 'neg', 'pow', 'reciprocal', 'relu', 'round', 'sigmoid', 'sin', 'sinh', 'softplus', 'softsign', 'sqrt', 'swish', 'tan', 'tanh', 'thresholded_relu'"abs", "acos", "asin", "atan", "ceil", "celu", "clip", "cos", "cosh", "elu", "erf", "exp", "floor", "gelu", "hard_sigmoid", "hard_swish", "log", "mish", "neg", "pow", "reciprocal", "relu", "round", "sigmoid", "sin", "sinh", "softplus", "softsign", "sqrt", "swish", "tan", "tanh", "thresholded_relu"

GenParamNamegenParamNamegen_param_name (input_control) attribute.name(-array) → (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

Generic input parameter names.

Default: [][]
List of values: 'alpha', 'approximate', 'beta', 'exponent', 'is_inference_output', 'max', 'min', 'upper_bound'"alpha", "approximate", "beta", "exponent", "is_inference_output", "max", "min", "upper_bound"

GenParamValuegenParamValuegen_param_value (input_control) attribute.value(-array) → (string / integer / real)HTuple (HString / Hlong / double)HTuple (string / int / long / double)MaybeSequence[Union[int, float, str]]Htuple (char* / Hlong / double)

Generic input parameter values.

Default: [][]
Suggested values: 'true', 'false', 'tanh'"true", "false", "tanh"

DLLayerActivationDLLayerActivationdllayer_activation (output_control) dl_layer → (handle)HTuple (HHandle)HDlLayer, HTuple (IntPtr)HHandleHtuple (handle)

Activation layer.

Module🔗

Deep Learning Professional