Importing data from CSV to tensor flow, Invalid Argument Error

Viewed 621

I am trying to use data i have in CSV files for training. To use them I'm following these instructions: https://www.tensorflow.org/api_guides/python/reading_data#QueueRunner

since my data are no integers but decimals i have changed

record_defaults = [[1], [1], [1], [1], [1]]

to record_defaults = [[1.], [1.], [1.], [1.], [1.]] so it accepts floats.

I still get following error though:

tensorflow.python.framework.errors_impl.InvalidArgumentError: Field 0 in record 0 is not a valid float: 15.5

[[Node: DecodeCSV = DecodeCSV[OUT_TYPE=[DT_FLOAT, ... , DT_FLOAT], field_delim=";", na_value="", select_cols=[], use_quote_delim=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](ReaderReadV2:1, DecodeCSV/record_defaults_0, ... , DecodeCSV/record_defaults_0)]]

Which doesn't make sense to me, 15.5 is in fact the first cell from my CSV file and if it isn't a float, what else?

any help on how to eat with this would be greatly appreciated

1 Answers

It appears to be a known issue with Tensorflow when reading CSV using the UTF-8 + BOM encoding. You should use your favorite (non notepad) text editor to convert the file to a normal UTF-8 encoding then it should read the csv properly.

Issue for reference: https://github.com/tensorflow/tensorflow/issues/8415

Related