Created
June 18, 2017 17:26
-
-
Save kudkudak/5aa4be2b8812b6f93ade61027084a4da to your computer and use it in GitHub Desktop.
stan_was_stupid.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import theano | |
import theano.tensor as T | |
import keras.backend as K | |
import numpy as np | |
x = T.fmatrix() | |
mask = T.ones_like(x[:, 0]) | |
mask = mask.dimshuffle(0, "x") | |
mask = K.dropout(mask, 0.5) | |
fnc = theano.function([x], mask) | |
print fnc(np.array([[1,2,3.], [4,5,6], [7,8,9]]).astype("float32")) | |
print fnc(np.array([[1,2,3.], [4,5,6], [7,8,9]]).astype("float32")) | |
print fnc(np.array([[1,2,3.], [4,5,6], [7,8,9]]).astype("float32")) | |
""" | |
Outputs: | |
[[ 2.] | |
[ 0.] | |
[ 2.]] | |
[[ 2.] | |
[ 0.] | |
[ 2.]] | |
[[ 0.] | |
[ 0.] | |
[ 2.]] | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment