kelvinxu / arctic-captions

960 stars 349 forks source link

MissingInputError from theano.function #3

Closed hyunseokmin closed 9 years ago

hyunseokmin commented 9 years ago

Hello, thank you for sharing.

I tried to generate caption for my image. To that end, I follows your code. I made a model file with capgen.train function (using Flickr8k data and default parameters).

Based on the model, I tried to generate a caption. However, I meet an error. The error is ...


MissingInputError Traceback (most recent call last)

in () 1 # get the alphas and selector value [called \beta in the paper] ----> 2 f_alpha = theano.function(inps, alphas, name='f_alpha') 3 if options['selector']: 4 f_sels = theano.function(inps, opt_outs['selector'], name='f_sels') /usr/local/lib/python2.7/dist-packages/Theano-0.7.0-py2.7.egg/theano/compile/function.pyc in function(inputs, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input) 264 allow_input_downcast=allow_input_downcast, 265 on_unused_input=on_unused_input, --> 266 profile=profile) 267 # We need to add the flag check_aliased inputs if we have any mutable or 268 # borrowed used defined inputs /usr/local/lib/python2.7/dist-packages/Theano-0.7.0-py2.7.egg/theano/compile/pfunc.pyc in pfunc(params, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input) 509 return orig_function(inputs, cloned_outputs, mode, 510 accept_inplace=accept_inplace, name=name, profile=profile, --> 511 on_unused_input=on_unused_input) 512 513 /usr/local/lib/python2.7/dist-packages/Theano-0.7.0-py2.7.egg/theano/compile/function_module.pyc in orig_function(inputs, outputs, mode, accept_inplace, name, profile, on_unused_input) 1463 accept_inplace=accept_inplace, 1464 profile=profile, -> 1465 on_unused_input=on_unused_input).create( 1466 defaults) 1467 /usr/local/lib/python2.7/dist-packages/Theano-0.7.0-py2.7.egg/theano/compile/function_module.pyc in **init**(self, inputs, outputs, mode, accept_inplace, function_builder, profile, on_unused_input, fgraph) 1131 need_opt = True 1132 # make the fgraph (copies the graph, creates NEW INPUT AND OUTPUT VARIABLES) -> 1133 fgraph, additional_outputs = std_fgraph(inputs, outputs, accept_inplace) 1134 fgraph.profile = profile 1135 else: /usr/local/lib/python2.7/dist-packages/Theano-0.7.0-py2.7.egg/theano/compile/function_module.pyc in std_fgraph(input_specs, output_specs, accept_inplace) 139 orig_outputs = [spec.variable for spec in output_specs] + updates 140 --> 141 fgraph = gof.fg.FunctionGraph(orig_inputs, orig_outputs) 142 143 for node in fgraph.apply_nodes: /usr/local/lib/python2.7/dist-packages/Theano-0.7.0-py2.7.egg/theano/gof/fg.pyc in **init**(self, inputs, outputs, features, clone) 133 self.variables.add(input) 134 --> 135 self.**import_r**(outputs, reason="init") 136 for i, output in enumerate(outputs): 137 output.clients.append(('output', i)) /usr/local/lib/python2.7/dist-packages/Theano-0.7.0-py2.7.egg/theano/gof/fg.pyc in **import_r**(self, variables, reason) 255 for apply_node in [r.owner for r in variables if r.owner is not None]: 256 if apply_node not in self.apply_nodes: --> 257 self.**import**(apply_node, reason=reason) 258 for r in variables: 259 if r.owner is None and not isinstance(r, graph.Constant) and r not in self.inputs: /usr/local/lib/python2.7/dist-packages/Theano-0.7.0-py2.7.egg/theano/gof/fg.pyc in **import**(self, apply_node, check, reason) 360 "for more information on this error." 361 % str(node)), --> 362 r) 363 364 for node in new_nodes: MissingInputError: ("An input of the graph, used to compute dot(, decoder_Wd_att), was not provided and not given a value.Use the Theano flag exception_verbosity='high',for more information on this error.", ) --- I start ipython with theano parameter as "THEANO_FLAGS=device=gpu,floatX=float32 ipython notebook" Do I have mistakes? Thank you.
kelvinxu commented 9 years ago

Strange, this works for me. How did you obtain your model? Did you just use the default parameters in the train function in capgen.py?

hyunseokmin commented 9 years ago

Yes. I used the default parameters in the train function in capgen.py.

hyunseokmin commented 9 years ago

it is more detail error description.

MissingInputError: A variable that is an input to the graph was neither provided as an input to the function nor given a value. A chain of variables leading from this input to an output is [<TensorType(float32, matrix)>, dot.0, DimShuffle{0,x,1}.0, Subtensor{::, ::, ::}.0, Elemwise{add,no_inplace}.0, Elemwise{tanh,no_inplace}.0, DimShuffle{0,1,2}.0, Reshape{2}.0, dot.0, Reshape{3}.0, Elemwise{add,no_inplace}.0, Reshape{2}.0, Elemwise{mul,no_inplace}.0, Softmax.0, Subtensor{::, int64}.0, Shape.0, Elemwise{Cast{int32}}.0, mrg_uniform{TensorType(float32, vector),no_inplace}.0]. This chain may not be unique Backtrace when the variable is created: File "capgen.py", line 511, in lstm_cond_layer n_steps=nsteps, profile=False)

kelvinxu commented 9 years ago

I was able to reproduce the bug. Thanks for helping me find it. I'll push a fix soon.

kelvinxu commented 9 years ago

I just pushed a fix, let me know if it solves your problem.

hyunseokmin commented 9 years ago

Thanks. It works. ^^: