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.