Continuation from previous question: Tensorflow - TypeError: 'int' object is not iterable
My training data is a list of lists each comprised of 1000 floats. F
This is a HIGHLY misleading error, as this is basically a general error, which might have NOTHING to do with floats.
For example in my case it was caused by a string column of the pandas dataframe having some np.NaN
values in it. Go figure!
Fixed it by replacing them with empty strings:
df.fillna(value='', inplace=True)
Or to be more specific doing this ONLY for the string (eg 'object') columns:
cols = df.select_dtypes(include=['object'])
for col in cols.columns.values:
df[col] = df[col].fillna('')
You may want to check data types in input data set or array and than convert it to float32
:
train_X[:2, :].view()
#array([[4.6, 3.1, 1.5, 0.2],
# [5.9, 3.0, 5.1, 1.8]], dtype=object)
train_X = train_X.astype(np.float32)
#array([[4.6, 3.1, 1.5, 0.2],
# [5.9, 3. , 5.1, 1.8]], dtype=float32)