Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AI and Deep Learning by (50.2k points)

 I have worked all the tutorials and searched for "load csv tensorflow" but just can't get the logic of it all. I'm not a total beginner, but I don't have much time to complete this, and I've been suddenly thrown into Tensorflow, which is unexpectedly difficult.

Let me lay it out:

A very simple CSV file of 184 columns that are all float numbers. A row is simply today's price, three buy signals, and the previous 180 days prices

close = tf.placeholder(float, name='close')

signals = tf.placeholder(bool, shape=[3], name='signals')

previous = tf.placeholder(float, shape=[180], name = 'previous')

This article: https://www.tensorflow.org/guide/datasets It covers how to load pretty well. It even has a section on changing to numpy arrays, which is what I need to train and test the 'net. However, as the author says in the article leading to this Web page, it is pretty complex. It seems like everything is geared toward doing data manipulation, where we have already normalized our data (nothing has really changed in AI since 1983 in terms of inputs, outputs, and layers).

Here is a way to load it, but not into Numpy and no example of not manipulating the data. 

with tf.Session as sess:

  sess.run( tf.global variables initializer())

  with open('/BTC1.csv') as csv_file:

    csv_reader = csv.reader(csv_file, delimiter =',')

    line_count = 0

    for row in csv_reader:

      ?????????

      line_count += 1

I need to know how to get the CSV file into the

close = tf.placeholder(float, name='close')

signals = tf.placeholder(bool, shape=[3], name='signals')

previous = tf.placeholder(float, shape=[180], name = 'previous')

so that I can follow the tutorials to train and test the net.

1 Answer

0 votes
by (108k points)

For loading the CSV with tf.data you can refer the following link:

https://www.tensorflow.org/beta/tutorials/load_data/csv

In order to utilize a Dataset we need three steps:

  • First, we have to import the data. Create a Dataset instance from some data
  • Then we will create an iterator. By using the imported dataset to make an Iterator instance to iterate through the dataset
  • At last, we will consume the data. By using the above-created iterator we can get the elements from the dataset to feed the model.

 You can refer the following link for better understanding:

https://towardsdatascience.com/how-to-use-dataset-in-tensorflow-c758ef9e4428

If you wish to know more about TensorFlow then visit this TensorFlow Tutorial.

Browse Categories

...