Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in example NB #7

Closed
twiecki opened this issue May 24, 2017 · 12 comments
Closed

Exception in example NB #7

twiecki opened this issue May 24, 2017 · 12 comments

Comments

@twiecki
Copy link

twiecki commented May 24, 2017

I'm up-to-date on pymc3 and gelato.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/Users/twiecki/anaconda/lib/python3.6/site-packages/theano/gof/op.py in __call__(self, *inputs, **kwargs)
    624                 try:
--> 625                     storage_map[ins] = [self._get_test_value(ins)]
    626                     compute_map[ins] = [True]

/Users/twiecki/anaconda/lib/python3.6/site-packages/theano/gof/op.py in _get_test_value(cls, v)
    580         detailed_err_msg = utils.get_variable_trace_string(v)
--> 581         raise AttributeError('%s has no test value %s' % (v, detailed_err_msg))
    582 

AttributeError: Softmax.0 has no test value  
Backtrace when that variable is created:

  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/ipykernel/zmqshell.py", line 533, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2717, in run_cell
    interactivity=interactivity, compiler=compiler, result=result)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2821, in run_ast_nodes
    if self.run_code(code, result):
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-18-7dd01309b711>", line 37, in <module>
    prediction = gelato.layers.get_output(network)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/lasagne/layers/helper.py", line 190, in get_output
    all_outputs[layer] = layer.get_output_for(layer_inputs, **kwargs)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/lasagne/layers/dense.py", line 124, in get_output_for
    return self.nonlinearity(activation)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/lasagne/nonlinearities.py", line 44, in softmax
    return theano.tensor.nnet.softmax(x)


During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-18-7dd01309b711> in <module>()
     44                    prediction,
     45                    observed=target_var,
---> 46                    total_size=total_size)

/Users/twiecki/working/projects/pymc/pymc3/distributions/distribution.py in __new__(cls, name, *args, **kwargs)
     35                 raise TypeError("observed needs to be data but got: {}".format(type(data)))
     36             total_size = kwargs.pop('total_size', None)
---> 37             dist = cls.dist(*args, **kwargs)
     38             return model.Var(name, dist, data, total_size)
     39         else:

/Users/twiecki/working/projects/pymc/pymc3/distributions/distribution.py in dist(cls, *args, **kwargs)
     46     def dist(cls, *args, **kwargs):
     47         dist = object.__new__(cls)
---> 48         dist.__init__(*args, **kwargs)
     49         return dist
     50 

/Users/twiecki/working/projects/pymc/pymc3/distributions/discrete.py in __init__(self, p, *args, **kwargs)
    429         super(Categorical, self).__init__(*args, **kwargs)
    430         try:
--> 431             self.k = tt.shape(p)[-1].tag.test_value
    432         except AttributeError:
    433             self.k = tt.shape(p)[-1]

/Users/twiecki/anaconda/lib/python3.6/site-packages/theano/gof/op.py in __call__(self, *inputs, **kwargs)
    637                         raise ValueError(
    638                             'Cannot compute test value: input %i (%s) of Op %s missing default value. %s' %
--> 639                             (i, ins, node, detailed_err_msg))
    640                     elif config.compute_test_value == 'ignore':
    641                         # silently skip test

ValueError: Cannot compute test value: input 0 (Softmax.0) of Op Shape(Softmax.0) missing default value.  
Backtrace when that variable is created:

  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/ipykernel/zmqshell.py", line 533, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2717, in run_cell
    interactivity=interactivity, compiler=compiler, result=result)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2821, in run_ast_nodes
    if self.run_code(code, result):
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-18-7dd01309b711>", line 37, in <module>
    prediction = gelato.layers.get_output(network)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/lasagne/layers/helper.py", line 190, in get_output
    all_outputs[layer] = layer.get_output_for(layer_inputs, **kwargs)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/lasagne/layers/dense.py", line 124, in get_output_for
    return self.nonlinearity(activation)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/lasagne/nonlinearities.py", line 44, in softmax
    return theano.tensor.nnet.softmax(x)
@twiecki
Copy link
Author

twiecki commented Jun 17, 2017

@ferrine any idea?

@ferrine
Copy link
Owner

ferrine commented Jun 17, 2017

I think that can be caused by our changing flags in context. You can try to set compute_test_value='raise'

@twiecki
Copy link
Author

twiecki commented Jun 22, 2017

@ferrine that didn't help.

@ferrine
Copy link
Owner

ferrine commented Jun 22, 2017

Ok I'll rerun it on weekends

@ferrine
Copy link
Owner

ferrine commented Jun 24, 2017

It worked

@twiecki
Copy link
Author

twiecki commented Jun 25, 2017

Now getting a different error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/anaconda/lib/python3.6/site-packages/theano/gof/op.py in __call__(self, *inputs, **kwargs)
    624                 try:
--> 625                     storage_map[ins] = [self._get_test_value(ins)]
    626                     compute_map[ins] = [True]

~/anaconda/lib/python3.6/site-packages/theano/gof/op.py in _get_test_value(cls, v)
    580         detailed_err_msg = utils.get_variable_trace_string(v)
--> 581         raise AttributeError('%s has no test value %s' % (v, detailed_err_msg))
    582 

AttributeError: AdvancedSubtensor1.0 has no test value  
Backtrace when that variable is created:

  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 235, in dispatch_shell
    handler(stream, idents, msg)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 399, in execute_request
    user_expressions, allow_stdin)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/ipykernel/ipkernel.py", line 196, in do_execute
    res = shell.run_cell(code, store_history=store_history, silent=silent)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/ipykernel/zmqshell.py", line 533, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2698, in run_cell
    interactivity=interactivity, compiler=compiler, result=result)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2802, in run_ast_nodes
    if self.run_code(code, result):
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2862, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-3-d01dfc616598>", line 6, in <module>
    target_var = target_var[ridx]


During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-18-7dd01309b711> in <module>()
     44                    prediction,
     45                    observed=target_var,
---> 46                    total_size=total_size)

~/working/projects/pymc/pymc3/distributions/distribution.py in __new__(cls, name, *args, **kwargs)
     37             total_size = kwargs.pop('total_size', None)
     38             dist = cls.dist(*args, **kwargs)
---> 39             return model.Var(name, dist, data, total_size)
     40         else:
     41             raise TypeError("Name needs to be a string but got: {}".format(name))

~/working/projects/pymc/pymc3/model.py in Var(self, name, dist, data, total_size)
    543                 var = ObservedRV(name=name, data=data,
    544                                  distribution=dist,
--> 545                                  total_size=total_size, model=self)
    546             self.observed_RVs.append(var)
    547             if var.missing_values:

~/working/projects/pymc/pymc3/model.py in __init__(self, type, owner, index, name, data, distribution, total_size, model)
    958         if type is None:
    959             data = pandas_to_array(data)
--> 960             type = TensorType(distribution.dtype, data.shape)
    961 
    962         self.observations = data

~/anaconda/lib/python3.6/site-packages/theano/tensor/var.py in <lambda>(self)
    273             return theano.tensor.basic.transpose(self, axes)
    274 
--> 275     shape = property(lambda self: theano.tensor.basic.shape(self))
    276 
    277     size = property(lambda self: self.shape[0] if self.ndim == 1 else

~/anaconda/lib/python3.6/site-packages/theano/gof/op.py in __call__(self, *inputs, **kwargs)
    637                         raise ValueError(
    638                             'Cannot compute test value: input %i (%s) of Op %s missing default value. %s' %
--> 639                             (i, ins, node, detailed_err_msg))
    640                     elif config.compute_test_value == 'ignore':
    641                         # silently skip test

ValueError: Cannot compute test value: input 0 (AdvancedSubtensor1.0) of Op Shape(AdvancedSubtensor1.0) missing default value.  
Backtrace when that variable is created:

  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 235, in dispatch_shell
    handler(stream, idents, msg)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 399, in execute_request
    user_expressions, allow_stdin)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/ipykernel/ipkernel.py", line 196, in do_execute
    res = shell.run_cell(code, store_history=store_history, silent=silent)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/ipykernel/zmqshell.py", line 533, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2698, in run_cell
    interactivity=interactivity, compiler=compiler, result=result)
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2802, in run_ast_nodes
    if self.run_code(code, result):
  File "/Users/twiecki/anaconda/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2862, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-3-d01dfc616598>", line 6, in <module>
    target_var = target_var[ridx]

@ferrine
Copy link
Owner

ferrine commented Jun 25, 2017

what is your theano.config.compute_test_value?

@ferrine ferrine mentioned this issue Jun 25, 2017
@twiecki
Copy link
Author

twiecki commented Jun 25, 2017 via email

@ferrine
Copy link
Owner

ferrine commented Jun 25, 2017

Could you please git pull and rerun?

@ferrine
Copy link
Owner

ferrine commented Jun 25, 2017

seems like get_output is called without computing test value. Try to set warn in the NB header and rerun

@twiecki
Copy link
Author

twiecki commented Jun 25, 2017

That did the trick (just pulling), thanks!

@ferrine ferrine closed this as completed Jul 5, 2017
@ferrine
Copy link
Owner

ferrine commented Jul 5, 2017

Closed the issue as it seems to be solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants