Skip to content

Instantly share code, notes, and snippets.

@RenSys
Last active June 22, 2018 12:08
Show Gist options
  • Save RenSys/0ef2639a96a67359bfdfb04a66c56b26 to your computer and use it in GitHub Desktop.
Save RenSys/0ef2639a96a67359bfdfb04a66c56b26 to your computer and use it in GitHub Desktop.
Theano - Matrices Sigmoidal Transfer
from theano import function
from theano import tensor as T
# (theano Tutorial)[http://deeplearning.net/software/theano/tutorial/examples.html]
# create a symbolic matrix
x = T.dmatrix('x')
# Method 1
# symbolic function
out = 1 / (1 + T.exp(-x))
f = function([x], out)
print f([[0, 1], [-1, -2]])
# Method 1
s2 = (1 + T.tanh(x / 2)) / 2
logistic2 = function([x], s2)
print logistic2([[0, 1], [-1, -2]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment