我在运行 TensorFlow 的 Wide_n_deep_tutorial 程序时遇到问题 https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/learn/wide_n_deep_tutorial.py我的个人数据集上有变化的是参数。我正在从 S3 加载数据。
我的目标变量是“impression_flag”,其值为“TRUE”或“FALSE”。下面是train_and_eval方法的代码片段:
def train_and_eval():
"""Train and evaluate the model."""
train_file_name, test_file_name = maybe_download()
df_train = pd.read_csv(
tf.gfile.Open(train_file_name),
names=COLUMNS,
skipinitialspace=True)
df_test = pd.read_csv(
tf.gfile.Open(test_file_name),
names=COLUMNS,
skipinitialspace=True,
skiprows=1)
df_train[LABEL_COLUMN] = (
df_train["impression_flag"].apply(lambda x: "TRUE" in x)).astype(int)
df_test[LABEL_COLUMN] = (
df_test["impression_flag"].apply(lambda x: "TRUE" in x)).astype(int)
model_dir = tempfile.mkdtemp() if not FLAGS.model_dir else FLAGS.model_dir
print("model directory = %s" % model_dir)
m = build_estimator(model_dir)
m.fit(input_fn=lambda: input_fn(df_train), steps=FLAGS.train_steps)
results = m.evaluate(input_fn=lambda: input_fn(df_test), steps=1)
for key in sorted(results):
print("%s: %s" % (key, results[key]))
运行代码时,显示错误“Type Error: argument of type 'float' is not iterable”。以下是错误的截图。 enter image description here
如有任何帮助,我们将不胜感激!
最佳答案
我也遇到了同样的问题,原来是第一行的NAN
引起的。请检查这个答案:https://stackoverflow.com/a/40223208/5318060
关于python - 类型错误 : argument of type 'float' is not iterable-Tensorflow wide_n_deep_tutorial,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39643505/