view tvii/sigmoid.py @ 19:cd43ce453358

[numpy] of course we have to cast everything here too
author Jeff Hammel <k0scist@gmail.com>
date Sun, 03 Sep 2017 20:46:26 -0700
parents bf8bd42f8cd7
children 38aa9098bf2d
line wrap: on
line source

"""
sigmoid function: 1/(1 + e^-z)
"""

import numpy as np
from .iterable import isiterable

def sigmoid(z):
    """https://en.wikipedia.org/wiki/Sigmoid_function"""
    if not isinstance(z, np.ndarray) and isiterable(z):
        z = np.array(z)
    return 1./(1. + np.exp(-z))