utils.act_func module
RosenPy: An Open Source Python Framework for Complex-Valued Neural Networks. Copyright © A. A. Cruz, K. S. Mayer, D. S. Arantes.
License:
This file is part of RosenPy. RosenPy is an open source framework distributed under the terms of the GNU General Public License, as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. For additional information on license terms, please open the Readme.md file.
RosenPy is distributed in the hope that it will be useful to every user, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with RosenPy. If not, see <http://www.gnu.org/licenses/>.
- utils.act_func.acos(module, x, derivative=False)[source]
Activation function - Arc cosine, element-wise.
- Parameters:
module (module) – Backend module, typically np or cp (CuPy).
x (array_like) – Input array.
derivative (bool, optional) – Whether to compute the derivative. Default is False.
- Returns:
Either the activation function (feedforward) or its derivative (backpropagation).
- Return type:
array_like
- utils.act_func.asin(module, x, derivative=False)[source]
Activation function - Arc sine, element-wise.
- Parameters:
module (module) – Backend module, typically np or cp (CuPy).
x (array_like) – Input array.
derivative (bool, optional) – Whether to compute the derivative. Default is False.
- Returns:
Either the activation function (feedforward) or its derivative (backpropagation).
- Return type:
array_like
- utils.act_func.asinh(module, x, derivative=False)[source]
Activation function - Inverse hyperbolic sine, element-wise.
- Parameters:
module (module) – Backend module, typically np or cp (CuPy).
x (array_like) – Input array.
derivative (bool, optional) – Whether to compute the derivative. Default is False.
- Returns:
Either the activation function (feedforward) or its derivative (backpropagation).
- Return type:
array_like
- utils.act_func.atan(module, x, derivative=False)[source]
Activation function - Arc tangent, element-wise.
- Parameters:
module (module) – Backend module, typically np or cp (CuPy).
x (array_like) – Input array.
derivative (bool, optional) – Whether to compute the derivative. Default is False.
- Returns:
Either the activation function (feedforward) or its derivative (backpropagation).
- Return type:
array_like
- utils.act_func.atanh(module, x, derivative=False)[source]
Activation function - Inverse hyperbolic tangent, element-wise.
- Parameters:
module (module) – Backend module, typically np or cp (CuPy).
x (array_like) – Input array.
derivative (bool, optional) – Whether to compute the derivative. Default is False.
- Returns:
Either the activation function (feedforward) or its derivative (backpropagation).
- Return type:
array_like
- utils.act_func.linear(module, x, derivative=False)[source]
Linear activation function, also known as “no activation” or “identity function.”
- Parameters:
module (module) – Backend module, typically np or cp (CuPy).
x (array_like) – Input array.
derivative (bool, optional) – Whether to compute the derivative. Default is False.
- Returns:
Either the activation function (feedforward) or its derivative (backpropagation).
- Return type:
array_like
- utils.act_func.sech(module, x, derivative=False)[source]
Activation function - Hyperbolic secant, element-wise.
- Parameters:
module (module) – Backend module, typically np or cp (CuPy).
x (array_like) – Input array.
derivative (bool, optional) – Whether to compute the derivative. Default is False.
- Returns:
Either the activation function (feedforward) or its derivative (backpropagation).
- Return type:
array_like
- utils.act_func.sin(module, x, derivative=False)[source]
Activation function - Sine, element-wise.
- Parameters:
module (module) – Backend module, typically np or cp (CuPy).
x (array_like) – Input array.
derivative (bool, optional) – Whether to compute the derivative. Default is False.
- Returns:
Either the activation function (feedforward) or its derivative (backpropagation).
- Return type:
array_like
- utils.act_func.sinh(module, x, derivative=False)[source]
Activation function - Hyperbolic sine, element-wise.
- Parameters:
module (module) – Backend module, typically np or cp (CuPy).
x (array_like) – Input array.
derivative (bool, optional) – Whether to compute the derivative. Default is False.
- Returns:
Either the activation function (feedforward) or its derivative (backpropagation).
- Return type:
array_like
- utils.act_func.split_complex(module, y, act_func, derivative=False)[source]
Applies activation functions separately to the real and imaginary components of a complex input.
- Parameters:
module (module) – Backend module, typically np or cp (CuPy).
y (array_like) – Input array.
act_func (function) – Activation function to be applied to both components.
derivative (bool, optional) – Whether to compute the derivative. Default is False.
- Returns:
Result of applying the activation function (or its derivative) to the real and imaginary parts.
- Return type:
array_like
- utils.act_func.tan(module, x, derivative=False)[source]
Activation function - Tangent, element-wise.
- Parameters:
module (module) – Backend module, typically np or cp (CuPy).
x (array_like) – Input array.
derivative (bool, optional) – Whether to compute the derivative. Default is False.
- Returns:
Either the activation function (feedforward) or its derivative (backpropagation).
- Return type:
array_like
- utils.act_func.tanh(module, x, derivative=False)[source]
Activation function - Hyperbolic tangent, element-wise.
- Parameters:
module (module) – Backend module, typically np or cp (CuPy).
x (array_like) – Input array.
derivative (bool, optional) – Whether to compute the derivative. Default is False.
- Returns:
Either the activation function (feedforward) or its derivative (backpropagation).
- Return type:
array_like