imgutils.utils.func

This module provides mathematical functions related to neural networks.

It includes the sigmoid activation function, which is commonly used in various machine learning and deep learning models. The sigmoid function maps any input value to a value between 0 and 1, making it useful for binary classification problems and as an activation function in neural network layers.

Usage:
>>> from imgutils.utils import sigmoid
>>> result = sigmoid(input_value)

sigmoid

imgutils.utils.func.sigmoid(x)[source]

Compute the sigmoid function for the input.

The sigmoid function is defined as: \(f\left(x\right) = \frac{1}{1 + e^{-x}}\)

This function applies the sigmoid activation to either a single number or an array of numbers using NumPy for efficient computation.

Parameters:

x (float or numpy.ndarray) – Input value or array of values.

Returns:

Sigmoid of the input.

Return type:

float or numpy.ndarray

Example:
>>> import numpy as np
>>> sigmoid(0)
0.5
>>> sigmoid(np.array([-1, 0, 1]))
array([0.26894142, 0.5       , 0.73105858])