Perturbation Functions

class perturbation.Bidirectional(delta=0.1)[source]

Calculates perturbations for positive and negative changes.

Parameters:

delta (float) – Percetage of positive and negative change as 1+delta or 1-delta

Return type:

4d array

Returns:

Both of perturbated arrays

class perturbation.Binary(th=0, upper=1, lower=0)[source]

Applies a binary perturbation to the input array based on a threshold.

Parameters:
  • th (float) – Threshold value for binary perturbation.

  • upper (float) – Value to set if input is above the threshold.

  • lower (float) – Value to set if input is below the threshold.

Return type:

4d array

Returns:

Perturbated array

class perturbation.Constant(c=0)[source]

Replaces all values in the input array with a constant.

Parameters:

c (float) – The constant value.

Return type:

4d array

Returns:

Perturbated array

class perturbation.Custom(custom)[source]

Applies a custom function as a perturbation to the array.

Parameters:

func (callable) – A function that takes a single argument and returns a single value.

Return type:

4d array

Returns:

Custom perturbated array

class perturbation.Exp(exp=2)[source]

Applies an exponential perturbation to the input array.

Parameters:

exp (float) – The exponent for the perturbation.

Return type:

4d array

Returns:

Perturbated array

class perturbation.Gaussian(mean=1, stdv=1)[source]

Applies a Gaussian perturbation to the input array.

Parameters:
  • mean (float) – Mean of the Gaussian distribution.

  • stdv (float) – Standard deviation of the Gaussian distribution.

Return type:

4d array

Returns:

Perturbated array

class perturbation.GaussianNoise(mean=1, stdv=1)[source]

Applies Gaussian noise to the input array.

Parameters:
  • mean (float) – Mean of the Gaussian distribution.

  • stdv (float) – Standard deviation of the Gaussian distribution.

Return type:

4d array

Returns:

Perturbated array

class perturbation.Inverse[source]

Applies an inverse perturbation to the input array.

Return type:

4d array

Returns:

Perturbated array

class perturbation.LeakyReLU(alpha=1)[source]

Applies a Leaky Rectified Linear Unit (LeakyReLU) perturbation to the input array.

Parameters:

alpha (float) – Coefficient for negative inputs in LeakyReLU.

Return type:

4d array

Returns:

Perturbated array

class perturbation.Log(base=10)[source]

Applies a logarithmic perturbation to the input array.

Parameters:

base (int) – The base of the logarithm.

Return type:

4d array

Returns:

Perturbated array

class perturbation.LowerThreshold(th=0, c=0)[source]

Sets values below a certain threshold to a specified value.

Parameters:
  • threshold (float) – Threshold below which values will be set to a specific value.

  • value (float) – Value to which entries below the threshold will be set.

Return type:

4d array

Returns:

Array with lower threshold applied

class perturbation.Negative(delta=0.1)[source]

Applies a negative perturbation to the input array.

Parameters:

delta (float) – Percentage of negative change as 1-delta

Return type:

4d array

Returns:

Perturbated array

class perturbation.Offset(offset=1)[source]

Applies an offset to the input array.

Parameters:

offset (float) – The value to be added to the input array.

Return type:

4d array

Returns:

Perturbated array

class perturbation.Positive(delta=0.1)[source]

Applies a positive perturbation to the input array.

Parameters:

delta (float) – Percentage of positive change as 1+delta

Return type:

4d array

Returns:

Perturbated array

class perturbation.RandomPtn(r=(0, 1))[source]

Applies a random perturbation to the input array.

Parameters:

r (tuple) – The range of random values for perturbation.

Return type:

4d array

Returns:

Perturbated array

class perturbation.ReLU[source]

Applies a Rectified Linear Unit (ReLU) perturbation to the input array.

Return type:

4d array

Returns:

Perturbated array

class perturbation.Sigmoid(sf=1)[source]

Applies a sigmoid perturbation to the input array.

Parameters:

sf (float) – Scale factor to apply before the sigmoid function.

Return type:

4d array

Returns:

Perturbated array

class perturbation.Sinusoidal(freq=30, amp=1)[source]

Applies a sinusoidal perturbation to the input array.

Parameters:
  • freq (float) – Frequency of the sine wave.

  • amp (float) – Amplitude of the sine wave.

Return type:

4d array

Returns:

Perturbated array

class perturbation.Softplus(sf=1)[source]

Applies a Softplus perturbation to the input array.

Parameters:

sf (float) – Scale factor to apply before the Softplus function.

Return type:

4d array

Returns:

Perturbated array

class perturbation.Tanh(sf=1)[source]

Applies a hyperbolic tangent perturbation to the input array.

Parameters:

sf (float) – Scale factor to apply before the tanh function.

Return type:

4d array

Returns:

Perturbated array

class perturbation.UniformNoise(lower=-1, upper=1)[source]

Applies uniform noise to the input array.

Parameters:
  • lower (float) – Lower bound of the uniform distribution.

  • upper (float) – Upper bound of the uniform distribution.

Return type:

4d array

Returns:

Perturbated array

class perturbation.UpperThreshold(th=0, c=0)[source]

Sets values above a certain threshold to a specified value.

Parameters:
  • threshold (float) – Threshold above which values will be set to a specific value.

  • value (float) – Value to which entries above the threshold will be set.

Return type:

4d array

Returns:

Array with upper threshold applied