我一直在使用本示例here。
我遇到的问题是,第一次运行后出现错误:
> train()
Extracting MNIST-data/train-images-idx3-ubyte.gz
Extracting MNIST-data/train-labels-idx1-ubyte.gz
Extracting MNIST-data/t10k-images-idx3-ubyte.gz
Extracting MNIST-data/t10k-labels-idx1-ubyte.gz
/Users/----/.virtualenvs/r-tensorflow/lib/python2.7/site-packages/tensorflow/python/client/session.py:1714: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s).
warnings.warn('An interactive session is already active. This can '
Error in py_call_impl(callable, dots$args, dots$keywords) :
InvalidArgumentError: You must feed a value for placeholder tensor 'input/y-input' with dtype float and shape [?,10]
[[Node: input/y-input = Placeholder[dtype=DT_FLOAT, shape=[?,10], _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
或者我遇到了另一个错误:
> train()
Extracting MNIST-data/train-images-idx3-ubyte.gz
Extracting MNIST-data/train-labels-idx1-ubyte.gz
Extracting MNIST-data/t10k-images-idx3-ubyte.gz
Extracting MNIST-data/t10k-labels-idx1-ubyte.gz
Error in py_call_impl(callable, dots$args, dots$keywords) :
InvalidArgumentError: You must feed a value for placeholder tensor 'input/y-input' with dtype float and shape [?,10]
[[Node: input/y-input = Placeholder[dtype=DT_FLOAT, shape=[?,10], _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
我尝试在函数末尾添加sess$close()
,但这并不能解决任何问题。
如何多次运行脚本而不会出现错误?就像如果我想在退出或最大步数混乱之后尝试再次运行。我也希望这样做,这样就不必每次都重新启动R。