0

I have the following piece of code which works in tf1.3 and tf1.4. When I try it in t1.2, the code runs but just hangs. I am only using tf1.2 because I want test to on Google cloud ml-engine and the engine only supports tf1.2 at this stage:

Here is my input CSV file:

A   B   Result
2   2   4
2   3   5

Here is my code:

csv_defaults = OrderedDict([("A", [0]), ("B", [0]), ("Result", [0])]);
file_path = "InputFile.csv";

def csv_decoder(line):
    parsed = tf.decode_csv(line, list(csv_defaults.values()), field_delim="\t");
    return parsed[0];

def test():
    dataset = (TextLineDataset(file_path)
                .skip(1)
                .map(csv_decoder)
                .batch(512));
    iterator = dataset.make_one_shot_iterator();
    columns = iterator.get_next();
    return columns;

input_fn = test();
with tf.Session() as sess:
    columns = sess.run(input_fn);
    print(columns);

This is the output in tf 1.4

[2 2]

When I run the same code in tf 1.2, the code just hangs and does not return anything..

I know from https://github.com/tensorflow/tensorflow/issues/13751 that in tf 1.2, the parse_csv function cannot return a dict, tuple or namedtuple (I have also tried them all). So I have stripped it right down to returning just a tensor. In the bug, @mrry recommends extracting the values for features and then creating a tuple by hand. The function parser(record) returns a tensor and seems to work. My parse_csv also returns a tensor but it still does not work. Can someone please help me?

Sorry if I am missing something obvious. I have only been using tf for the last few weeks and have searched a lot for answers.

  • I just attempted to run your code in TensorFlow 1.2, and it successfully printed `[2 2]`. Did you perhaps change something in the example before posting it? – mrry Oct 23 '17 at 15:24
  • Thank you mrry. Nope this is the exact code I tried. After your comment, I tried the same code on my home desktop with with tf1.2 and, like you, i found that it works. So I think this is a problem with google ml-engine. When I install tensorflow1.3.0 in my local environment, the code works. But when I install tensorflow1.2.0 I run into the problem described above. I have also tried running this on the cloud ml-engine and that doesnt work either. Can you please help?Ive edited the tags to google cloud. please let me know if you need any clarifications – MarquesDeCampo Oct 26 '17 at 13:32

0 Answers0