例如,在解压缩文件时,我可以使用~
而不是/home/username/
指向文件路径.zip
。
但是,今天,当我按照同样的方式在终端中运行RNN示例时,tensorflow.python.framework.errors_impl.NotFoundError
就被抛出了。
$ python ptb_word_lm.py --data_path=~/anaconda2/lib/python2.7/site-packages/tensorflow/models-master/tutorials/rnn/simple-examples/data/ --model=small
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
Traceback (most recent call last):
File "ptb_word_lm.py", line 374, in <module>
tf.app.run()
File "/home/hok/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 44, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "ptb_word_lm.py", line 321, in main
raw_data = reader.ptb_raw_data(FLAGS.data_path)
File "/home/hok/anaconda2/lib/python2.7/site-packages/tensorflow/models-master/tutorials/rnn/ptb/reader.py", line 73, in ptb_raw_data
word_to_id = _build_vocab(train_path)
File "/home/hok/anaconda2/lib/python2.7/site-packages/tensorflow/models-master/tutorials/rnn/ptb/reader.py", line 34, in _build_vocab
data = _read_words(filename)
File "/home/hok/anaconda2/lib/python2.7/site-packages/tensorflow/models-master/tutorials/rnn/ptb/reader.py", line 30, in _read_words
return f.read().decode("utf-8").replace("\n", "<eos>").split()
File "/home/hok/anaconda2/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py", line 106, in read
self._preread_check()
File "/home/hok/anaconda2/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py", line 73, in _preread_check
compat.as_bytes(self.__name), 1024 * 512, status)
File "/home/hok/anaconda2/lib/python2.7/contextlib.py", line 24, in __exit__
self.gen.next()
File "/home/hok/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/errors_impl.py", line 469, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.NotFoundError: ~/anaconda2/lib/python2.7/site-packages/tensorflow/models-master/tutorials/rnn/simple-examples/data/ptb.train.txt
然后,我将其替换~
为/home/username/
,并且它可以正常工作。
为什么在运行RNN示例时不能使用~
而不是/home/username/
指向文件路径?
您能详细告诉我吗?
~
在将参数传递给python之前,外壳程序是否应该展开?就像shell会在路径中扩展反斜杠转义符一样,或者在路径被引用的情况下删除引号。
$VARIABLES
,~
只能在字符串的开头扩展。
exec
“d)应该是在UNIX工具广泛使用。