qiufengyuyi / event_extraction

baidu aistudio event extraction competition
MIT License
224 stars 39 forks source link

tf.estimator无法使用 #10

Open ddgetget opened 4 years ago

ddgetget commented 4 years ago

TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.

qiufengyuyi commented 3 years ago

TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.

信息有点不太具体,不过根据我的经验,这种错误往往发生在input_fn或者模型的输入这块有点问题,建议在这块debug一下

Chen-Dixi commented 3 years ago

TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.

请问找到问题原因了吗

Chen-Dixi commented 3 years ago

TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.

请问找到问题原因了吗

现在跑通了

Jorigorn commented 3 years ago

请问是什么问题呢? sh run_event_role.sh 后

aceback (most recent call last): File "run_event.py", line 73, in main() File "run_event.py", line 46, in main run_event_role_mrc(args) File "/data/ceph/dd/event_classification/ft_local/event_extraction_tiny/train_helper.py", line 182, in run_event_role_mrc tf.estimator.train_and_evaluate(estimator, train_spec, eval_spec) File "/usr/local/app/.pyenv/versions/env-3.6.8/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/training.py", line 473, in train_and_evaluate return executor.run() File "/usr/local/app/.pyenv/versions/env-3.6.8/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/training.py", line 613, in run return self.run_local() File "/usr/local/app/.pyenv/versions/env-3.6.8/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/training.py", line 714, in run_local saving_listeners=saving_listeners) File "/usr/local/app/.pyenv/versions/env-3.6.8/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 367, in train loss = self._train_model(input_fn, hooks, saving_listeners) File "/usr/local/app/.pyenv/versions/env-3.6.8/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1158, in _train_model return self._train_model_default(input_fn, hooks, saving_listeners) File "/usr/local/app/.pyenv/versions/env-3.6.8/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1188, in _train_model_default features, labels, ModeKeys.TRAIN, self.config) File "/usr/local/app/.pyenv/versions/env-3.6.8/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1146, in _call_model_fn model_fn_results = self._model_fn(features=features, **kwargs) File "/data/ceph/arikchen/event_classification/ft_local/event_extraction_tiny/models/bert_mrc.py", line 68, in model_fn start_labels,end_labels = labels File "/usr/local/app/.pyenv/versions/env-3.6.8/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 477, in iter "Tensor objects are only iterable when eager execution is " TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.

qiufengyuyi commented 3 years ago

请问是什么问题呢? sh run_event_role.sh 后

aceback (most recent call last): File "run_event.py", line 73, in main() File "run_event.py", line 46, in main run_event_role_mrc(args) File "/data/ceph/dd/event_classification/ft_local/event_extraction_tiny/train_helper.py", line 182, in run_event_role_mrc tf.estimator.train_and_evaluate(estimator, train_spec, eval_spec) File "/usr/local/app/.pyenv/versions/env-3.6.8/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/training.py", line 473, in train_and_evaluate return executor.run() File "/usr/local/app/.pyenv/versions/env-3.6.8/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/training.py", line 613, in run return self.run_local() File "/usr/local/app/.pyenv/versions/env-3.6.8/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/training.py", line 714, in run_local saving_listeners=saving_listeners) File "/usr/local/app/.pyenv/versions/env-3.6.8/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 367, in train loss = self._train_model(input_fn, hooks, saving_listeners) File "/usr/local/app/.pyenv/versions/env-3.6.8/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1158, in _train_model return self._train_model_default(input_fn, hooks, saving_listeners) File "/usr/local/app/.pyenv/versions/env-3.6.8/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1188, in _train_model_default features, labels, ModeKeys.TRAIN, self.config) File "/usr/local/app/.pyenv/versions/env-3.6.8/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1146, in _call_model_fn model_fn_results = self._model_fn(features=features, kwargs) File "/data/ceph/arikchen/event_classification/ft_local/event_extraction_tiny/models/bert_mrc.py", line 68, in model_fn start_labels,end_labels = labels File "/usr/local/app/.pyenv/versions/env-3.6.8/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 477, in iter** "Tensor objects are only iterable when eager execution is " TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.

见楼上的回答,可能是input的数据格式有问题,需要debug一下,看具体模型对应的正确的输入数据格式

veronic commented 3 years ago

TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.

请问找到问题原因了吗

现在跑通了

请问您是怎么调试成功的? 我依照作者在知乎里的回答“一种是多分类形式,一种是两个类型label,分别预测起始位置,你这个问题应该是模型用的是预测起始位置,但是实际上加载的label是多分类,建议你看一下代码,换成加载预测起始位置的数据”,把“train_helper.py”的118行和123行分别改成“labels_start_train.npy”和“labels_start_dev.npy”但还是会报错。

已经难过到心有戚戚、食不下咽、日夜垂泪的地步。

Chen-Dixi commented 3 years ago

TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.

请问找到问题原因了吗

现在跑通了

请问您是怎么调试成功的? 我依照作者在知乎里的回答“一种是多分类形式,一种是两个类型label,分别预测起始位置,你这个问题应该是模型用的是预测起始位置,但是实际上加载的label是多分类,建议你看一下代码,换成加载预测起始位置的数据”,把“train_helper.py”的118行和123行分别改成“labels_start_train.npy”和“labels_start_dev.npy”但还是会报错。

已经难过到心有戚戚、食不下咽、日夜垂泪的地步。

试试我fork出来的代码,https://github.com/Chen-Dixi/event_extraction

veronic commented 3 years ago

TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.

请问找到问题原因了吗

现在跑通了

请问您是怎么调试成功的? 我依照作者在知乎里的回答“一种是多分类形式,一种是两个类型label,分别预测起始位置,你这个问题应该是模型用的是预测起始位置,但是实际上加载的label是多分类,建议你看一下代码,换成加载预测起始位置的数据”,把“train_helper.py”的118行和123行分别改成“labels_start_train.npy”和“labels_start_dev.npy”但还是会报错。 已经难过到心有戚戚、食不下咽、日夜垂泪的地步。

试试我fork出来的代码,https://github.com/Chen-Dixi/event_extraction。

谢谢! 调通了,原来是少加了终止位置end_labels。 我终于又能吃得下饭了【泪目】

chunxiaozheng commented 3 years ago

TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.

请问找到问题原因了吗

现在跑通了

请问您是怎么调试成功的? 我依照作者在知乎里的回答“一种是多分类形式,一种是两个类型label,分别预测起始位置,你这个问题应该是模型用的是预测起始位置,但是实际上加载的label是多分类,建议你看一下代码,换成加载预测起始位置的数据”,把“train_helper.py”的118行和123行分别改成“labels_start_train.npy”和“labels_start_dev.npy”但还是会报错。 已经难过到心有戚戚、食不下咽、日夜垂泪的地步。

试试我fork出来的代码,https://github.com/Chen-Dixi/event_extraction。

谢谢! 调通了,原来是少加了终止位置end_labels。 我终于又能吃得下饭了【泪目】

你好,可以请教一下怎么修改的嘛,我也遇到了这个问题

chunxiaozheng commented 3 years ago

TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.

请问找到问题原因了吗

现在跑通了

你好,可以请教一下怎么调通的嘛,我看您分享的git地址404了

veronic commented 3 years ago

TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.

请问找到问题原因了吗

现在跑通了

你好,可以请教一下怎么调通的嘛,我看您分享的git地址404了

https://github.com/Chen-Dixi/event_extraction 是这个地址,之前那个最后加了“。”所以404了

chunxiaozheng commented 3 years ago

TypeError: Tensor objects are only iterable when eager execution is enabled. To iterate over this tensor use tf.map_fn.

请问找到问题原因了吗

现在跑通了

你好,可以请教一下怎么调通的嘛,我看您分享的git地址404了

https://github.com/Chen-Dixi/event_extraction 是这个地址,之前那个最后加了“。”所以404了

好的,我学习一下,太感谢啦!