You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code raises an error on the last line (when attempting to fit the model). However it works fine if mask_zero is set to False. It also works if base_model is added to a Sequential model.
import numpy as np
from keras.models import Model
from keras.layers import Input, Embedding, SimpleRNN, Dense
# Base model
base_inputs = Input(shape=(10, ))
embeddings = Embedding(input_dim=100,
output_dim=16,
mask_zero=True)(base_inputs)
base_out = SimpleRNN(32)(embeddings)
base_model = Model(base_inputs, base_out)
# Using the base model in another model, with the Functional API.
inputs = Input(shape=(10, ))
processed_inputs = base_model(inputs)
out = Dense(1)(processed_inputs)
model = Model(inputs, out)
model.compile(loss='mse', optimizer='rmsprop')
x = np.random.randint(0, 100, (1000, 10))
y = np.random.rand(1000)
model.fit(x, y, epochs=10)
Traceback using Tensorflow:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1022, in _do_call
return fn(*args)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1004, in _run_fn
status, run_metadata)
File "/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 89, in __exit__
next(self.gen)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 469, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'input_1' with dtype float
[[Node: input_1 = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "temp.py", line 26, in <module>
model.fit(x, y, epochs=10)
File "/usr/local/lib/python3.6/site-packages/keras/engine/training.py", line 1486, in fit
initial_epoch=initial_epoch)
File "/usr/local/lib/python3.6/site-packages/keras/engine/training.py", line 1141, in _fit_loop
outs = f(ins_batch)
File "/usr/local/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2102, in __call__
feed_dict=feed_dict)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 767, in run
run_metadata_ptr)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 965, in _run
feed_dict_string, options, run_metadata)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1015, in _do_run
target_list, options, run_metadata)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1035, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'input_1' with dtype float
[[Node: input_1 = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
Caused by op 'input_1', defined at:
File "temp.py", line 8, in <module>
base_inputs = Input(shape=(10, ))
File "/usr/local/lib/python3.6/site-packages/keras/engine/topology.py", line 1391, in Input
input_tensor=tensor)
File "/usr/local/lib/python3.6/site-packages/keras/engine/topology.py", line 1302, in __init__
name=self.name)
File "/usr/local/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 350, in placeholder
x = tf.placeholder(dtype, shape=shape, name=name)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 1520, in placeholder
name=name)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 2149, in _placeholder
name=name)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 763, in apply_op
op_def=op_def)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2395, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1264, in __init__
self._traceback = _extract_stack()
InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'input_1' with dtype float
[[Node: input_1 = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
Traceback using Theano:
Traceback (most recent call last):
File "temp.py", line 26, in <module>
model.fit(x, y, epochs=10)
File "/usr/local/lib/python3.6/site-packages/keras/engine/training.py", line 1458, in fit
self._make_train_function()
File "/usr/local/lib/python3.6/site-packages/keras/engine/training.py", line 1008, in _make_train_function
**self._function_kwargs)
File "/usr/local/lib/python3.6/site-packages/keras/backend/theano_backend.py", line 1132, in function
return Function(inputs, outputs, updates=updates, **kwargs)
File "/usr/local/lib/python3.6/site-packages/keras/backend/theano_backend.py", line 1118, in __init__
**kwargs)
File "/usr/local/lib/python3.6/site-packages/theano/compile/function.py", line 326, in function
output_keys=output_keys)
File "/usr/local/lib/python3.6/site-packages/theano/compile/pfunc.py", line 486, in pfunc
output_keys=output_keys)
File "/usr/local/lib/python3.6/site-packages/theano/compile/function_module.py", line 1808, in orig_function
output_keys=output_keys).create(
File "/usr/local/lib/python3.6/site-packages/theano/compile/function_module.py", line 1446, in __init__
accept_inplace)
File "/usr/local/lib/python3.6/site-packages/theano/compile/function_module.py", line 177, in std_fgraph
update_mapping=update_mapping)
File "/usr/local/lib/python3.6/site-packages/theano/gof/fg.py", line 174, in __init__
self.__import_r__(output, reason="init")
File "/usr/local/lib/python3.6/site-packages/theano/gof/fg.py", line 345, in __import_r__
self.__import__(variable.owner, reason=reason)
File "/usr/local/lib/python3.6/site-packages/theano/gof/fg.py", line 390, in __import__
raise MissingInputError(error_msg, variable=r)
theano.gof.fg.MissingInputError: Input 0 of the graph (indices start from 0), used to compute Elemwise{neq,no_inplace}(/input_1, InplaceDimShuffle{x,x}.0), was not provided and not given a value. Use the Theano flag exception_verbosity='high', for more information on this error.
Backtrace when that variable is created:
File "temp.py", line 8, in <module>
base_inputs = Input(shape=(10, ))
File "/usr/local/lib/python3.6/site-packages/keras/engine/topology.py", line 1391, in Input
input_tensor=tensor)
File "/usr/local/lib/python3.6/site-packages/keras/engine/topology.py", line 1302, in __init__
name=self.name)
File "/usr/local/lib/python3.6/site-packages/keras/backend/theano_backend.py", line 184, in placeholder
x = T.TensorType(dtype, broadcast)(name)
OS: Mac OS X
Keras: 2.0.2
Tensorflow (cpu): 1.0.0
Theano: 0.9.0
The text was updated successfully, but these errors were encountered:
The following code raises an error on the last line (when attempting to fit the model). However it works fine if mask_zero is set to False. It also works if base_model is added to a Sequential model.
Traceback using Tensorflow:
Traceback using Theano:
OS: Mac OS X
Keras: 2.0.2
Tensorflow (cpu): 1.0.0
Theano: 0.9.0
The text was updated successfully, but these errors were encountered: