我正在尝试运行示例tensorflow脚本:https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/mnist/mnist_with_summaries.py
当我第一次运行它时,我在运行结束时收到错误:
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:05:08)
Type "copyright", "credits" or "license" for more information.
IPython 5.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
runfile('/Users/max/Desktop/mnist_with_summaries.py', wdir='/Users/max/Desktop')
Extracting /tmp/tensorflow/mnist/input_data/train-images-idx3-ubyte.gz
Extracting /tmp/tensorflow/mnist/input_data/train-labels-idx1-ubyte.gz
Extracting /tmp/tensorflow/mnist/input_data/t10k-images-idx3-ubyte.gz
Extracting /tmp/tensorflow/mnist/input_data/t10k-labels-idx1-ubyte.gz
Accuracy at step 0: 0.141
Accuracy at step 10: 0.6992
Accuracy at step 20: 0.8042
Accuracy at step 30: 0.8514
Accuracy at step 40: 0.8786
Accuracy at step 50: 0.8867
Accuracy at step 60: 0.8941
Accuracy at step 70: 0.8891
Accuracy at step 80: 0.8925
Accuracy at step 90: 0.8983
Adding run metadata for 99
/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/IPython/core/interactiveshell.py:2889: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
An exception has occurred, use %tb to see the full traceback.
SystemExit
任何后续运行都会在加载数据后立即中断:
runfile('/Users/max/Desktop/mnist_with_summaries.py', wdir='/Users/max/Desktop')
Extracting /tmp/tensorflow/mnist/input_data/train-images-idx3-ubyte.gz
Extracting /tmp/tensorflow/mnist/input_data/train-labels-idx1-ubyte.gz
Extracting /tmp/tensorflow/mnist/input_data/t10k-images-idx3-ubyte.gz
Extracting /tmp/tensorflow/mnist/input_data/t10k-labels-idx1-ubyte.gz
Traceback (most recent call last):
File "<ipython-input-2-c176905abc5f>", line 1, in <module>
runfile('/Users/max/Desktop/mnist_with_summaries.py', wdir='/Users/max/Desktop')
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 94, in execfile
builtins.execfile(filename, *where)
File "/Users/max/Desktop/mnist_with_summaries.py", line 204, in <module>
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 43, in run
sys.exit(main(sys.argv[:1] + flags_passthrough))
File "/Users/max/Desktop/mnist_with_summaries.py", line 185, in main
train()
File "/Users/max/Desktop/mnist_with_summaries.py", line 160, in train
summary, acc = sess.run([merged, accuracy], feed_dict=feed_dict(False))
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 766, in run
run_metadata_ptr)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 964, in _run
feed_dict_string, options, run_metadata)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1014, in _do_run
target_list, options, run_metadata)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1034, in _do_call
raise type(e)(node_def, op, message)
InvalidArgumentError: You must feed a value for placeholder tensor 'input/x-input' with dtype float
[[Node: input/x-input = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
Caused by op u'input/x-input', defined at:
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/spyder/utils/ipython/start_kernel.py", line 227, in <module>
main()
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/spyder/utils/ipython/start_kernel.py", line 223, in main
kernel.start()
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/ipykernel/kernelapp.py", line 474, in start
ioloop.IOLoop.instance().start()
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/zmq/eventloop/ioloop.py", line 177, in start
super(ZMQIOLoop, self).start()
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/tornado/ioloop.py", line 887, in start
handler_func(fd_obj, events)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/tornado/stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/zmq/eventloop/zmqstream.py", line 440, in _handle_events
self._handle_recv()
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/zmq/eventloop/zmqstream.py", line 472, in _handle_recv
self._run_callback(callback, msg)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/zmq/eventloop/zmqstream.py", line 414, in _run_callback
callback(*args, **kwargs)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/tornado/stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/ipykernel/kernelbase.py", line 276, in dispatcher
return self.dispatch_shell(stream, msg)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/ipykernel/kernelbase.py", line 228, in dispatch_shell
handler(stream, idents, msg)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/ipykernel/kernelbase.py", line 390, in execute_request
user_expressions, allow_stdin)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/ipykernel/ipkernel.py", line 196, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/ipykernel/zmqshell.py", line 501, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2717, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2827, in run_ast_nodes
if self.run_code(code, result):
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-1-c176905abc5f>", line 1, in <module>
runfile('/Users/max/Desktop/mnist_with_summaries.py', wdir='/Users/max/Desktop')
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 94, in execfile
builtins.execfile(filename, *where)
File "/Users/max/Desktop/mnist_with_summaries.py", line 204, in <module>
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 43, in run
sys.exit(main(sys.argv[:1] + flags_passthrough))
File "/Users/max/Desktop/mnist_with_summaries.py", line 185, in main
train()
File "/Users/max/Desktop/mnist_with_summaries.py", line 48, in train
x = tf.placeholder(tf.float32, [None, 784], name='x-input')
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1587, in placeholder
name=name)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 2043, in _placeholder
name=name)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op
op_def=op_def)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2240, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/Users/max/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1128, in __init__
self._traceback = _extract_stack()
InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'input/x-input' with dtype float
[[Node: input/x-input = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
我所做的唯一改变是在代码的第193行中将循环次数从1000减少到100(但在任何情况下都会发生错误)。 我在Mac上使用Sypder和Python 2.
任何想法如何解决这个问题?安装可能有什么问题。
此外,代码应编写与tensorboard一起使用的摘要。这些文件存储在哪里?无法在模块(桌面)的位置找到它们。
非常感谢你的帮助!