【发布时间】:2017-11-20 21:17:46
【问题描述】:
我在 TensorFlow 中有多个特征列,我正在尝试创建循环以避免手动输入来创建特征列,但它不起作用。下面是我需要创建特征列的所有列的列表(这只是一个虚拟数据,但如果我们有数百列怎么办)。
num_preg = tf.feature_column.numeric_column('Number_pregnant')
glucose_conc = tf.feature_column.numeric_column('glucose_concentration')
blood_prs = tf.feature_column.numeric_column('blood_pressure')
Tricep = tf.feature_column.numeric_column('Triceps')
insulin = tf.feature_column.numeric_column('Insulin')
I created a loop for this as mentioned below, df_col_num is a list containing the column names for which I need to create feature column.
for col in df_col_num:
col= tf.feature_column.categorical_column_with_hash_bucket(col,hash_bucke[enter link description here][1]t_size=50)
任何帮助或建议将不胜感激。
谢谢!
【问题讨论】:
-
见stackoverflow.com/questions/46834680/…。基本上,如果您可以通过 pandas 加载数据(也可以应用过滤器),您可以遍历所有列,将每个列添加到功能列表中,而无需显式声明每个列。
-
很高兴听到。 :D
标签: tensorflow