Skip to content

Instantly share code, notes, and snippets.

@pwl
Created June 28, 2017 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pwl/9bf9b660d7bd6b79b95570ead03b0c93 to your computer and use it in GitHub Desktop.
Save pwl/9bf9b660d7bd6b79b95570ead03b0c93 to your computer and use it in GitHub Desktop.
AttributeError
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/opt/conda/lib/python3.5/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]
/opt/conda/lib/python3.5/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: <float32> has no test value
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
/opt/conda/lib/python3.5/site-packages/pymc3/variational/callbacks.py in record(self, approx, hist, i)
124 try:
--> 125 res = fn()
126 # if `*t` argument is used
/opt/conda/lib/python3.5/site-packages/theano/gof/graph.py in eval(self, inputs_to_values)
515 if inputs not in self._fn_cache:
--> 516 self._fn_cache[inputs] = theano.function(inputs, self)
517 args = [inputs_to_values[param] for param in inputs]
/opt/conda/lib/python3.5/site-packages/theano/compile/function.py in function(inputs, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input)
325 profile=profile,
--> 326 output_keys=output_keys)
327 # We need to add the flag check_aliased inputs if we have any mutable or
/opt/conda/lib/python3.5/site-packages/theano/compile/pfunc.py in pfunc(params, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input, output_keys)
485 profile=profile, on_unused_input=on_unused_input,
--> 486 output_keys=output_keys)
487
/opt/conda/lib/python3.5/site-packages/theano/compile/function_module.py in orig_function(inputs, outputs, mode, accept_inplace, name, profile, on_unused_input, output_keys)
1794 output_keys=output_keys).create(
-> 1795 defaults)
1796
/opt/conda/lib/python3.5/site-packages/theano/compile/function_module.py in create(self, input_storage, trustme, storage_map)
1660 _fn, _i, _o = self.linker.make_thunk(
-> 1661 input_storage=input_storage_lists, storage_map=storage_map)
1662 finally:
/opt/conda/lib/python3.5/site-packages/theano/gof/link.py in make_thunk(self, input_storage, output_storage, storage_map)
698 output_storage=output_storage,
--> 699 storage_map=storage_map)[:3]
700
/opt/conda/lib/python3.5/site-packages/theano/gof/vm.py in make_all(self, profiler, input_storage, output_storage, storage_map)
1046 no_recycling,
-> 1047 impl=impl))
1048 linker_make_thunk_time[node] = time.time() - thunk_start
/opt/conda/lib/python3.5/site-packages/theano/gof/op.py in make_thunk(self, node, storage_map, compute_map, no_recycling, impl)
934 return self.make_c_thunk(node, storage_map, compute_map,
--> 935 no_recycling)
936 except (NotImplementedError, utils.MethodNotDefined):
/opt/conda/lib/python3.5/site-packages/theano/gof/op.py in make_c_thunk(self, node, storage_map, compute_map, no_recycling)
838 outputs = cl.make_thunk(input_storage=node_input_storage,
--> 839 output_storage=node_output_storage)
840 fill_storage, node_input_filters, node_output_filters = outputs
/opt/conda/lib/python3.5/site-packages/theano/gof/cc.py in make_thunk(self, input_storage, output_storage, storage_map, keep_lock)
1189 input_storage, output_storage, storage_map,
-> 1190 keep_lock=keep_lock)
1191
/opt/conda/lib/python3.5/site-packages/theano/gof/cc.py in __compile__(self, input_storage, output_storage, storage_map, keep_lock)
1130 storage_map,
-> 1131 keep_lock=keep_lock)
1132 return (thunk,
/opt/conda/lib/python3.5/site-packages/theano/gof/cc.py in cthunk_factory(self, error_storage, in_storage, out_storage, storage_map, keep_lock)
1585 module = get_module_cache().module_from_key(
-> 1586 key=key, lnk=self, keep_lock=keep_lock)
1587
/opt/conda/lib/python3.5/site-packages/theano/gof/cmodule.py in module_from_key(self, key, lnk, keep_lock)
1121
-> 1122 src_code = lnk.get_src_code()
1123 # Is the source code already in the cache?
/opt/conda/lib/python3.5/site-packages/theano/gof/cc.py in get_src_code(self)
1461 def get_src_code(self):
-> 1462 mod = self.get_dynamic_module()
1463 return mod.code()
/opt/conda/lib/python3.5/site-packages/theano/gof/cc.py in get_dynamic_module(self)
1505 if not hasattr(self, '_mod'):
-> 1506 self.code_gen()
1507
/opt/conda/lib/python3.5/site-packages/theano/gof/cc.py in code_gen(self)
800 try:
--> 801 struct_init = op.c_init_code_struct(node, name, sub_struct)
802 assert isinstance(struct_init, string_types), (
/opt/conda/lib/python3.5/site-packages/theano/gpuarray/elemwise.py in c_init_code_struct(self, node, name, sub)
208 nargs = len(inps) + len(outs) - len(self.inplace_pattern)
--> 209 support_code, kop = self._generate_op_string(node)
210 res = """
/opt/conda/lib/python3.5/site-packages/theano/gpuarray/elemwise.py in _generate_op_string(self, node)
162 if isinstance(scalar_op, (scalar.Cast, Composite)):
--> 163 scalar_op = scalar_op.clone_float32()
164 fake_node = scalar_op.make_node(*scal_v_ins)
/opt/conda/lib/python3.5/site-packages/theano/scalar/basic.py in clone_float32(self)
3892 # This will not modify the fgraph or the nodes
-> 3893 new_ins, new_outs = composite_f32.apply(self.fgraph)
3894 return Composite(new_ins, new_outs)
/opt/conda/lib/python3.5/site-packages/theano/scalar/basic.py in apply(self, fgraph)
4057 if type(node.op) in self.special:
-> 4058 self.special[type(node.op)](node, mapping)
4059 continue
/opt/conda/lib/python3.5/site-packages/theano/scalar/basic.py in handle_composite(node, mapping)
4105 new_op = node.op.clone_float32()
-> 4106 new_outs = new_op(*[mapping[i] for i in node.inputs], return_list=True)
4107 assert len(new_outs) == len(node.outputs)
/opt/conda/lib/python3.5/site-packages/theano/gof/op.py in __call__(self, *inputs, **kwargs)
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':
ValueError: ('The following error happened while compiling the node', GpuElemwise{Composite{Switch(Identity((GE(i0, i1) * LE(i0, i2) * GE(i3, i4))), Switch(i5, (log(i0) + Switch(i6, i7, Switch(Identity(GE(i3, i4)), ((Switch(EQ(i3, i8), i9, (i10 * log(i3))) - i11) - i3), i12))), Switch(GT(((log(i0) - i3) - Composite{log1p((-i0))}(i0)), i13), ((log(i0) - i3) + scalar_softplus((-((log(i0) - i3) - Composite{log1p((-i0))}(i0))))), (Composite{log1p((-i0))}(i0) + scalar_softplus(((log(i0) - i3) - Composite{log1p((-i0))}(i0)))))), i14)}}[(0, 0)]<gpuarray>(InplaceGpuDimShuffle{x,0,1}.0, GpuArrayConstant{[[[0]]]}, GpuArrayConstant{[[[1]]]}, InplaceGpuDimShuffle{x,0,1}.0, GpuArrayConstant{[[[0]]]}, GpuArrayConstant{[[[ True True]
[ True True]]]}, GpuArrayConstant{[[[False]]]}, GpuArrayConstant{[[[0]]]}, GpuArrayConstant{[[[0]]]}, GpuArrayConstant{[[[-inf]]]}, GpuArrayConstant{[[[ 2. 1.]
[ 2. 1.]]]}, GpuArrayConstant{[[[ 0.69314718 0. ]
[ 0.69314718 0. ]]]}, GpuArrayConstant{[[[-inf]]]}, GpuArrayConstant{[[[0]]]}, GpuArrayConstant{[[[-inf]]]}), '\n', 'Cannot compute test value: input 0 (<float32>) of Op Composite{log1p((-i0))}(<float32>) missing default value. ')
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-6-b07e623ebee1> in <module>()
11 pm.ZeroInflatedPoisson.dist(theta=theta,psi=psi).logp(data),size=1)
12 inference.fit(n=2,
---> 13 callbacks=[pm.callbacks.Tracker(val=val.eval)])
/opt/conda/lib/python3.5/site-packages/pymc3/variational/inference.py in fit(self, n, score, callbacks, progressbar, **kwargs)
124 progress = tqdm.trange(n, disable=not progressbar)
125 if score:
--> 126 self._iterate_with_loss(n, step_func, progress, callbacks)
127 else:
128 self._iterate_without_loss(n, step_func, progress, callbacks)
/opt/conda/lib/python3.5/site-packages/pymc3/variational/inference.py in _iterate_with_loss(self, n, step_func, progress, callbacks)
174 'Average Loss = {:,.5g}'.format(avg_loss))
175 for callback in callbacks:
--> 176 callback(self.approx, scores[:i + 1], i)
177 except (KeyboardInterrupt, StopIteration) as e:
178 # do not print log on the same line
/opt/conda/lib/python3.5/site-packages/pymc3/variational/callbacks.py in record(self, approx, hist, i)
132 # to try fn(approx, hist, i) first
133 except Exception:
--> 134 res = fn(approx, hist, i)
135 self.hist[key].append(res)
136
TypeError: eval() takes from 1 to 2 positional arguments but 4 were given
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment