Activations

class utils.activations.Activations(name)[source]

Bases: object

Base Activation class object

Parameters

name (str) – Name of the activation function

ACTIVATION_INDEX = -1
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

property name

Get the name of the activation function

class utils.activations.Asymmetriclogistic[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 18
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.Elliot[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 14
STEEPNESS = 1.0
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.Elu[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 3
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.Hardtan[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 11
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.Leaky[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 9
LEAKY_COEF = 0.1
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.Lhtan[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 12
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.Linear[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 6
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.Loggy[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 1
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.Logistic[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 0
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.Plse[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 8
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.Ramp[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 5
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.Relie[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 4
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.Relu[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 2
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.Selu[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 13
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

utils.activations.Sigmoid

alias of utils.activations.Logistic

class utils.activations.SoftPlus[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 16
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.SoftSign[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 17
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.Stair[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 10
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.SymmElliot[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 15
STEEPNESS = 1.0
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

class utils.activations.Tanh[source]

Bases: utils.activations.Activations

ACTIVATION_INDEX = 7
static activate(x, copy=False)[source]

Abstract activation function

Parameters
  • x (array-like) – Input array to activate according to the desired function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

activated – The input array activated

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.

static gradient(x, copy=False)[source]

Abstract gradient function

Parameters
  • x (array-like) – Input array (already activated!) to evaluate according to the desired gradient function

  • copy (bool (default=False)) – Make a copy of the input array or just modify it

Returns

gradient – The gradient of the input array

Return type

array-like

Raises
  • The abstract method raises a NotImplementedError since the

  • Activation class is just an abstract base class for the

  • object.