【发布时间】:2019-11-03 06:58:01
【问题描述】:
我正在使用 TensorFlow 1.15 进行机器学习项目,在该项目中我使用 tf.feature_column 创建特征列,但遇到了一个错误。
我是这样定义feature columns的:
# Define feature columns
is_male = tf.feature_column.categorical_column_with_vocabulary_list('is_male', vocabulary_list=['False', 'True'])
plurality = tf.feature_column.categorical_column_with_vocabulary_list('plurality', vocabulary_list=['Single(1)', 'Twins(2)', 'Triplets(3)', 'Quadruplets(4)', 'Quintuplets(5)'])
wide_columns = [is_male, plurality]
mother_age = tf.feature_column.numeric_column(key="mother_age", shape=10)
gestation_weeks = tf.feature_column.numeric_column(key="gestation_weeks", shape=10)
deep_columns = [mother_age,gestation_weeks]
feature_cols = [wide_columns, deep_columns]
这是我得到的确切错误:
ValueError:feature_columns 的项目必须是 _FeatureColumn。给定(类型):[VocabularyListCategoricalColumn(key='is_male', words_list=('False', 'True'), dtype=tf.string, default_value=-1, num_oov_buckets=0), VocabularyListCategoricalColumn(key='plurality',词汇表=('Single(1)', 'Twins(2)', 'Triplets(3)', 'Quadruplets(4)', 'Quintuplets(5)'), dtype=tf.string, default_value=-1, num_oov_buckets=0)]。
【问题讨论】:
标签: python python-3.x tensorflow machine-learning linear-regression