Mercurial > hg > tvii
view tvii/sigmoid.py @ 42:38aa9098bf2d
derivative of sigmoid
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Mon, 04 Sep 2017 14:34:00 -0700 |
parents | cd43ce453358 |
children |
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)) def sigmoidprime(z): """"derivative of sigmoid""" return sigmoid(z)*(1-sigmoid(z))