我在个人数据集上运行TensorFlow https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/learn/wide_n_deep_tutorial.py的wide_n_deep_tutorial程序时遇到问题,其中变量是参数。我正在从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]))
在运行代码时,出现错误"类型错误:类型'浮动'是不可迭代的#34;被展示。以下是错误的屏幕截图。 enter image description here
任何帮助将不胜感激!