TypeError: 'float'类型的参数不是可迭代的- tensorflow wide_n_deep_tutorial

时间:2022-05-04 13:51:42

I am facing an issue while running the wide_n_deep_tutorial program of TensorFlow https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/learn/wide_n_deep_tutorial.py on my personal data set with variation is the parameters. I am loading my data from S3.

我在运行TensorFlow的wide_n_deep_tutorial程序时遇到了一个问题,这个程序的参数是我个人数据集上的参数。我正在从S3加载我的数据。

My target variable is "impression_flag" which the takes the value of either "TRUE" or "FALSE". Below is the code snippet of the train_and_eval method:

我的目标变量是“印象派”,它取“真”或“假”的值。下面是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]))

While running the code, an error "Type Error: argument of type 'float' is not iterable" is displayed. The following is the screenshot of the error. enter image description here

在运行代码时,将显示一个错误“类型错误:类型‘float’的参数不可迭代”。下面是错误的屏幕截图。在这里输入图像描述

Any help would be appreciated!

如有任何帮助,我们将不胜感激!

1 个解决方案

#1


1  

I got the same problem, it turns out to be caused by the NAN in the first line. Please checks this answer: https://*.com/a/40223208/5318060

我遇到了同样的问题,结果是由第一行的NAN引起的。请检查这个答案:https://*.com/a/40223208/5318060

#1


1  

I got the same problem, it turns out to be caused by the NAN in the first line. Please checks this answer: https://*.com/a/40223208/5318060

我遇到了同样的问题,结果是由第一行的NAN引起的。请检查这个答案:https://*.com/a/40223208/5318060