Keras Constant Input Layers with Fixed Source of Stochasticity
In [1]:
%matplotlib notebook
In [2]:
import numpy as np
import keras.backend as K
from keras.layers import Input, Activation, Add, GaussianNoise
from keras.models import Sequential, Model
Rationale¶
TODO
In [3]:
random_tensor = K.random_normal(shape=(8, 3), seed=42)
In [4]:
K.eval(random_tensor)
Out[4]:
In [5]:
K.eval(random_tensor)
Out[5]:
In [6]:
x = Input(shape=(784,))
eps = Input(tensor=K.random_normal(shape=(K.shape(x)[0], 3), seed=42))
In [7]:
try:
m = Model(x, eps)
except RuntimeError as e:
print(e)
In [8]:
m = Model([x, eps], eps)
In [9]:
m.predict(np.ones((8, 784)))
Out[9]:
In [10]:
m.predict([np.ones((8, 784))])
Out[10]:
In [11]:
try:
m.predict([np.ones((8, 784)), np.ones((8, 3))])
except ValueError as e:
print(e)
Comments
Comments powered by Disqus