我是张量流的新手。我正在关注本教程https://learningtensorflow.com/lesson9/
我的Python env是3.5.2,具有张量流1.9.0和numpy 1.15.0。我在Windows 10平台的Anaconda3中运行python env。该教程中的代码在Jupyter笔记本中运行。
运行时
with tf.Session() as session:
initial_board_values = session.run(initial_board)
X = session.run(board_update, feed_dict={board: initial_board_values})[0]`
我得到如下错误:
UnimplementedError Traceback (most recent call last)
~\AppData\Local\conda\conda\envs\py3\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
1321 try:
-> 1322 return fn(*args)
1323 except errors.OpError as e:
~\AppData\Local\conda\conda\envs\py3\lib\site-packages\tensorflow\python\client\session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
1306 return self._call_tf_sessionrun(
-> 1307 options, feed_dict, fetch_list, target_list, run_metadata)
1308
~\AppData\Local\conda\conda\envs\py3\lib\site-packages\tensorflow\python\client\session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
1408 self._session, options, feed_dict, fetch_list, target_list,
-> 1409 run_metadata)
1410 else:
UnimplementedError: Unsupported numpy type 5
[[Node: PyFunc_1 = PyFunc[Tin=[DT_INT32], Tout=[DT_INT32], token="pyfunc_1", _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_board_1_0_0)]]
During handling of the above exception, another exception occurred:
UnimplementedError Traceback (most recent call last)
<ipython-input-10-d85af0ec9968> in <module>()
1 with tf.Session() as session:
2 initial_board_values = session.run(initial_board)
----> 3 X = session.run(board_update, feed_dict={board: initial_board_values})[0]
~\AppData\Local\conda\conda\envs\py3\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata)
898 try:
899 result = self._run(None, fetches, feed_dict, options_ptr,
--> 900 run_metadata_ptr)
901 if run_metadata:
902 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
~\AppData\Local\conda\conda\envs\py3\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
1133 if final_fetches or final_targets or (handle and feed_dict_tensor):
1134 results = self._do_run(handle, final_targets, final_fetches,
-> 1135 feed_dict_tensor, options, run_metadata)
1136 else:
1137 results = []
~\AppData\Local\conda\conda\envs\py3\lib\site-packages\tensorflow\python\client\session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
1314 if handle is None:
1315 return self._do_call(_run_fn, feeds, fetches, targets, options,
-> 1316 run_metadata)
1317 else:
1318 return self._do_call(_prun_fn, handle, feeds, fetches)
~\AppData\Local\conda\conda\envs\py3\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
1333 except KeyError:
1334 pass
-> 1335 raise type(e)(node_def, op, message)
1336
1337 def _extend_graph(self):
UnimplementedError: Unsupported numpy type 5
[[Node: PyFunc_1 = PyFunc[Tin=[DT_INT32], Tout=[DT_INT32], token="pyfunc_1", _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_board_1_0_0)]]
Caused by op 'PyFunc_1', defined at:
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\ipykernel_launcher.py", line 16, in <module>
app.launch_new_instance()
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
app.start()
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\ipykernel\kernelapp.py", line 477, in start
ioloop.IOLoop.instance().start()
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\zmq\eventloop\ioloop.py", line 177, in start
super(ZMQIOLoop, self).start()
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\tornado\ioloop.py", line 888, in start
handler_func(fd_obj, events)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\zmq\eventloop\zmqstream.py", line 440, in _handle_events
self._handle_recv()
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\zmq\eventloop\zmqstream.py", line 472, in _handle_recv
self._run_callback(callback, msg)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\zmq\eventloop\zmqstream.py", line 414, in _run_callback
callback(*args, **kwargs)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\ipykernel\kernelbase.py", line 235, in dispatch_shell
handler(stream, idents, msg)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\ipykernel\kernelbase.py", line 399, in execute_request
user_expressions, allow_stdin)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\ipykernel\ipkernel.py", line 196, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\ipykernel\zmqshell.py", line 533, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\IPython\core\interactiveshell.py", line 2698, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\IPython\core\interactiveshell.py", line 2802, in run_ast_nodes
if self.run_code(code, result):
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\IPython\core\interactiveshell.py", line 2862, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-8-8d546cf3ed00>", line 2, in <module>
board_update = tf.py_func(update_board, [board], [tf.int32])
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\tensorflow\python\ops\script_ops.py", line 384, in py_func
func=func, inp=inp, Tout=Tout, stateful=stateful, eager=False, name=name)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\tensorflow\python\ops\script_ops.py", line 227, in _internal_py_func
input=inp, token=token, Tout=Tout, name=name)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\tensorflow\python\ops\gen_script_ops.py", line 130, in py_func
"PyFunc", input=input, token=token, Tout=Tout, name=name)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\tensorflow\python\framework\ops.py", line 3414, in create_op
op_def=op_def)
File "C:\Users\Pillar\AppData\Local\conda\conda\envs\py3\lib\site-packages\tensorflow\python\framework\ops.py", line 1740, in __init__
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access
UnimplementedError (see above for traceback): Unsupported numpy type 5
[[Node: PyFunc_1 = PyFunc[Tin=[DT_INT32], Tout=[DT_INT32], token="pyfunc_1", _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_board_1_0_0)]]