我在Google Colab上使用TF 2.0。我从大多数代码中复制了Tensorflow“加载CSV数据”教程,并为我的培训和eval / test csv文件更改了一些配置变量。运行它时,出现了此错误(仅显示最后一帧,完整输出为here:
在
NUMERIC_FEATURES = ['microtime', 'dist']
packed_train_data = raw_train_data.map(
PackNumericFeatures(NUMERIC_FEATURES))
packed_test_data = raw_test_data.map(
PackNumericFeatures(NUMERIC_FEATURES))
出
/tensorflow-2.0.0/python3.6/tensorflow_core/python/autograph/impl/api.py in wrapper(*args, **kwargs)
235 except Exception as e: # pylint:disable=broad-except
236 if hasattr(e, 'ag_error_metadata'):
--> 237 raise e.ag_error_metadata.to_exception(e)
238 else:
239 raise
KeyError: in converted code:
<ipython-input-19-85ea56f80c91>:6 __call__ *
numeric_features = [features.pop(name) for name in self.names]
/tensorflow-2.0.0/python3.6/tensorflow_core/python/autograph/impl/api.py:396 converted_call
return py_builtins.overload_of(f)(*args)
KeyError: 'dist'
答案 0 :(得分:0)
当签名包含用户代码中可能发生的错误时,将使用“转换后的代码”。在这种情况下,以下类似内容是相关的:
<ipython-input-19-85ea56f80c91>:6 __call__ *
numeric_features = [features.pop(name) for name in self.names]
该错误消息缺少一些关键信息,我们应该对其进行纠正,但是它建议调用features.pop(name)
会引发KeyError
,因此很可能features
中缺少该密钥。>