hunkim / word-rnn-tensorflow

Multi-layer Recurrent Neural Networks (LSTM, RNN) for word-level language models in Python using TensorFlow.
MIT License
1.3k stars 494 forks source link

Error when trying to train. #81

Open probablyrei opened 6 years ago

probablyrei commented 6 years ago

When I open train.py I get a traceback error that says:

Traceback (most recent call last): File "C:\Users\User\Desktop\word-rnn-tensorflow-master\train.py", line 134, in main() File "C:\Users\User\Desktop\word-rnn-tensorflow-master\train.py", line 54, in main train(args) File "C:\Users\User\Desktop\word-rnn-tensorflow-master\train.py", line 57, in train data_loader = TextLoader(args.data_dir, args.batch_size, args.seq_length, args.input_encoding) File "C:\Users\User\Desktop\word-rnn-tensorflow-master\utils.py", line 23, in init self.preprocess(input_file, vocab_file, tensor_file, encoding) File "C:\Users\User\Desktop\word-rnn-tensorflow-master\utils.py", line 65, in preprocess with codecs.open(input_file, "r", encoding=encoding) as f: File "C:\Users\User\AppData\Local\Programs\Python\Python35\lib\codecs.py", line 895, in open file = builtins.open(filename, mode, buffering) FileNotFoundError: [Errno 2] No such file or directory: 'data/tinyshakespeare\input.txt'

I don't know why it says "No such file or directory: 'data/tinyshakespeare\input.txt'" because it is definitely there..help?

Enviy commented 6 years ago

I received this error at first as well. I had to ensure that I was in the same directory as the 'data' folder.

probablyrei commented 5 years ago

I received this error at first as well. I had to ensure that I was in the same directory as the 'data' folder.

Can you please elaborate on what you mean by that?

normanheckscher commented 5 years ago

Looks like filesystem directory structure naming issue. Forward and backward slashes.

"data/tinyshakespeare\input.txt"

On Sat., 20 Oct. 2018, 13:22 probablyrei, notifications@github.com wrote:

I received this error at first as well. I had to ensure that I was in the same directory as the 'data' folder.

Can you please elaborate on what you mean by that?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hunkim/word-rnn-tensorflow/issues/81#issuecomment-431544440, or mute the thread https://github.com/notifications/unsubscribe-auth/AF86NHgyiOvUd_sh9RGH987Bmvwx5D_Aks5umpbqgaJpZM4VaTow .

Enviy commented 5 years ago

That's a good point about the backslash. At first I thought it was escaping a space character but there shouldn't be a space there so it's odd.

So earlier I mentioned ensuring you were in the 'data' directory. What I meant is that when I encountered a similar issue, it worked when I navigated to the project directory which had the 'data' directory in it. The script has default args which look for the input file in that directory.

micooke commented 5 years ago

The problem is the formation of the default value for --data_dir https://github.com/hunkim/word-rnn-tensorflow/blob/master/train.py#L15

You can change this line locally to default=os.join('data','tinyshakespeare') or pass thus parameter when you can it python train --data_dir data\\tinyshakespeare