tensorflow / tensorflow/probability
Failed to convert a NumPy array to a Tensor (Unsupported numpy type: NPY_INT)
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 4.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
I haven't been able to figure this one out since the code works perfectly on a hosted runtime of Google Colab and as soon as I move to a local runtime running on Windows 10 I get this error that comes from constant_op.py when I call sample_chain of tfp.mcmc. Any ideas? Thank you!
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_core\python\framework\constant_op.py", line 96, in convert_to_eager_tensor
return ops.EagerTensor(value, ctx.device_name, dtype)
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_core\python\framework\constant_op.py", line 266, in _constant_impl
t = convert_to_eager_tensor(value, ctx, dtype)
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_core\python\framework\constant_op.py", line 258, in constant
allow_broadcast=True)
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_core\python\framework\tensor_conversion_registry.py", line 52, in _default_conversion_function
return constant_op.constant(value, dtype, name=name)
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_core\python\framework\ops.py", line 1314, in convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_core\python\ops\math_ops.py", line 705, in cast
x = ops.convert_to_tensor(x, name="x")
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_core\python\util\dispatch.py", line 180, in wrapper
return target(*args, **kwargs)
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_probability\python\math\generic.py", line 111, in reduce_logmeanexp
log_n = tf.math.log(tf.cast(n, lse.dtype))
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_probability\python\mcmc\simple_step_size_adaptation.py", line 380, in one_step
axis=prefer_static.range(num_reduce_dims))
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_probability\python\mcmc\internal\util.py", line 315, in <lambda>
body=lambda i, *args: [i + 1] + list(body_fn(*args)),
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_core\python\ops\control_flow_ops.py", line 2714, in while_loop
loop_vars = body(*loop_vars)
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_core\python\ops\control_flow_ops.py", line 2478, in while_loop_v2
return_same_structure=True)
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_probability\python\mcmc\internal\util.py", line 317, in smart_for_loop
parallel_iterations=parallel_iterations
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_probability\python\mcmc\sample.py", line 343, in _trace_scan_fn
parallel_iterations=parallel_iterations)
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_probability\python\mcmc\internal\util.py", line 384, in _body
state = loop_fn(state, elems_array.read(i))
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_core\python\ops\control_flow_ops.py", line 2714, in while_loop
loop_vars = body(*loop_vars)
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_core\python\ops\control_flow_ops.py", line 2478, in while_loop_v2
return_same_structure=True)
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_probability\python\mcmc\internal\util.py", line 395, in trace_scan
parallel_iterations=parallel_iterations)
File "C:\Users\emore\Anaconda3\Lib\site-packages\tensorflow_probability\python\mcmc\sample.py", line 359, in sample_chain
parallel_iterations=parallel_iterations)
File "C:\Users\emore\Documents\covid19 analysis\code\test.py", line 479, in graph_sample_chain
out = tensorflow_probability.mcmc.sample_chain(*args, **kwargs)
File "C:\Users\emore\Documents\covid19 analysis\code\test.py", line 527, in <module>
kernel = kernel, parallel_iterations=nchain)
File "C:\Users\emore\Anaconda3\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\emore\Anaconda3\Lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Users\emore\Anaconda3\Lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "C:\Users\emore\Anaconda3\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\emore\Anaconda3\Lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The failure is reported through tensorflow_core/python/framework/constant_op.py and tensorflow_probability/python/math/generic.py during mcmc.sample_chain, with the caller in test.py. First compare the local Windows 10 Python, NumPy, and TensorFlow Probability environment with the hosted Colab runtime and reduce the call to sample_chain; done means the NPY_INT conversion error is reproduced, its environment difference is identified, and the call works locally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100