pfunctions¶
Module contents¶
-
class
poornn.pfunctions.
PReLU
(input_shape, itype, leak=0.1, var_mask=[True])¶ Bases:
poornn.core.ParamFunction
Parametric ReLU,
\begin{align} f(x)=\text{relu}(x)=\begin{cases} x, &\Re[x]>0\\ \text{leak}\cdot x,&\Re[x]<0 \end{cases} \end{align}where leak is a trainable parameter if var_mask[0] is True.
Parameters: - leak (float, default=0.1) – leakage,
- var_mask (1darray<bool>, default=[True]) – variable mask
-
leak
¶ float – leakage,
-
var_mask
¶ 1darray<bool> – variable mask
-
set_runtime_vars
(var_dict={})¶ Set runtime variables for layers.
Parameters: var_dict (dict) – the runtime variables dict.
-
class
poornn.pfunctions.
Poly
(input_shape, itype, params, kernel='polynomial', var_mask=None, factorial_rescale=False)¶ Bases:
poornn.core.ParamFunction
Ploynomial function layer.
- e.g. for polynomial kernel, we have
- \(f(x) = \sum\limits_i \text{params}[i]x^i/i!\) (factorial_rescale is True)
- \(f(x) = \sum\limits_i \text{params}[i]x^i\) (factorial_rescale is False)
Parameters: - kernel (str, default='polynomial') – the kind of polynomial serie expansion, see Poly.kernel_dict for detail.
- factorial_rescale (bool, default=False) – rescale high order factors to avoid overflow.
- var_mask (1darray<bool>, default=(True,True,..)) – variable mask
-
kernel
¶ str – the kind of polynomial serie expansion, see Poly.kernel_dict for detail.
-
factorial_rescale
¶ bool – rescale high order factors to avoid overflow.
-
var_mask
¶ 1darray<bool> – variable mask
-
kernel_dict
= {'chebyshev': <class 'numpy.polynomial.chebyshev.Chebyshev'>, 'legendre': <class 'numpy.polynomial.legendre.Legendre'>, 'hermiteE': <class 'numpy.polynomial.hermite_e.HermiteE'>, 'hermite': <class 'numpy.polynomial.hermite.Hermite'>, 'laguerre': <class 'numpy.polynomial.laguerre.Laguerre'>, 'polynomial': <class 'numpy.polynomial.polynomial.Polynomial'>}¶ dict of available kernels, with values target functions.
-
max_order
¶ int – maximum order appeared.
-
set_runtime_vars
(var_dict={})¶ Set runtime variables for layers.
Parameters: var_dict (dict) – the runtime variables dict.
-
class
poornn.pfunctions.
Mobius
(input_shape, itype, params, var_mask=None)¶ Bases:
poornn.core.ParamFunction
Mobius transformation, \(f(x) = \frac{(z-a)(b-c)}{(z-c)(b-a)}\)
\(a, b, c\) map to \(0, 1, \infty\) respectively.
-
set_runtime_vars
(var_dict={})¶ Set runtime variables for layers.
Parameters: var_dict (dict) – the runtime variables dict.
-
-
class
poornn.pfunctions.
Georgiou1992
(input_shape, itype, params, var_mask=None)¶ Bases:
poornn.core.ParamFunction
Function \(f(x) = \frac{x}{c+|x|/r}\)
-
set_runtime_vars
(var_dict={})¶ Set runtime variables for layers.
Parameters: var_dict (dict) – the runtime variables dict.
-
-
class
poornn.pfunctions.
Gaussian
(input_shape, itype, params, var_mask=None)¶ Bases:
poornn.core.ParamFunction
Function \(f(x) = \frac{1}{\sqrt{2\pi}\sigma} \exp(-\frac{\|x-\mu\|^2}{2\sigma^2})\), where \(\mu,\sigma\) are mean and variance respectively.
-
set_runtime_vars
(var_dict={})¶ Set runtime variables for layers.
Parameters: var_dict (dict) – the runtime variables dict.
-
-
class
poornn.pfunctions.
PMul
(input_shape, itype, c=1.0, var_mask=None)¶ Bases:
poornn.core.ParamFunction
Function \(f(x) = cx\), where c is trainable if var_mask[0] is True.
Parameters: c (number, default=1.0) – multiplier. -
c
¶ number – multiplier.
-
set_runtime_vars
(var_dict={})¶ Set runtime variables for layers.
Parameters: var_dict (dict) – the runtime variables dict.
-