-1

Using the tensorflow website, I am learning to make a RNN. This is how the website says to upload a dataset:

# Dataset
path_to_file = tf.keras.utils.get_file('shakespeare.txt', 
    'https://storage.googleapis.com/download.tensorflow.org/data/shakespeare.txt')

But I was wondering if there was a way for me to use a text file I already have saved on my computer, instead of this one, and if so, how do I do this?

Sorry if this is a very stupid question, but I will appreciate any help, thank you.

Mahirah
  • 25
  • 5
  • Does this answer your question? [How to read a file line-by-line into a list?](https://stackoverflow.com/questions/3277503/how-to-read-a-file-line-by-line-into-a-list) – Nicolas Gervais Jul 30 '20 at 03:36

1 Answers1

0

get_file needs an URL to download via network. You cannot just download from a local directory.

If you wanted to read in a txt from your local disk you would have to open it with other methods, depending on what you want to do later. For example you could read in a txt like using

mytxt = open(r'C:\folder\shakespeare.txt').read().lower()

or something like this

x_values=np.genfromtxt(r'C:\folder\shakespeare.txt', delimiter=' ',  dtype=None, encoding=None)

(delimiter and so depends on your txt file, you have to choose what fits you)

if you want to use it later with Keras.

Stat Tistician
  • 813
  • 5
  • 17
  • 45