From the TensorFlow docs it\'s clear how to use tf.feature_column.categorical_column_with_vocabulary_list
to create a feature column which takes as input some strin
you should use tf.feature_column.indicator_column see https://www.tensorflow.org/versions/master/api_docs/python/tf/feature_column/indicator_column
Here is an example how to feed data to the indicator column:
features = {'letter': [['A','A'], ['C','D'], ['E','F'], ['G','A'], ['X','R']]}
letter_feature = tf.feature_column.categorical_column_with_vocabulary_list(
"letter", ["A", "B", "C"], dtype=tf.string)
indicator = tf.feature_column.indicator_column(letter_feature)
tensor = tf.feature_column.input_layer(features, [indicator])
with tf.Session() as session:
session.run(tf.global_variables_initializer())
session.run(tf.tables_initializer())
print(session.run([tensor]))
Which outputs:
[array([[2., 0., 0.],
[0., 0., 1.],
[0., 0., 0.],
[1., 0., 0.],
[0., 0., 0.]], dtype=float32)]