代码之家  ›  专栏  ›  技术社区  ›  Michael

TypeError:不支持在下一个(<class“generator”)上调用

  •  0
  • Michael  · 技术社区  · 6 年前

    在以下代码中:

    self.estimator = tf.estimator.DNNRegressor( ... )
    ...
    predictions = self.estimator.predict(predict_features)
    print("predictions: {}".format(type(predictions)))
    while True:
      try:
        result = next(predictions)
        predict_labels.append(result)
      except StopIteration:
        return predict_labels
    

    class 'generator' result = next(predictions) 在第0次迭代中生成了此异常:

    TypeError: unsupported callable
    

    0 回复  |  直到 6 年前