ValueError: Feature not in features dictionary
When using tf.feature_columns
, the data you feed in your input_fn should have the same keys as the feature columns previously created.
So, the x
of your train_input_fn
should be a dictionary, with keys named after the feature_columns
.
A mock example :
x = {"policy_state": np.array(['AL','AL','AL','AL','AL']),
"modern_classic_ind": np.array(['0','0','0','0','0']),
"h_plus_ind": np.array(['0','0','0','0','0']),}
On the side :
This great article from the developers google blog could be a great read, as it introduces a new way to create input_fn
directly from a csv file with the tf.Dataset
API. It has a better memory management, and avoid loading all the dataset into memory.
I have the same problem but when i checked the names of my columns of database, there was a little mistake in the name of column. Check out your column's names.
If you use your using an already existing dataset, it is advised to rename the columns.