从parser_trainer_test.sh训练语法网络(导入错误:无法导入名称tf_logging)



我是python和SyntaxNet的新手,我正在尝试从SyntaxNet Tutorial中训练SyntaxNet。为了训练模型,我根据教程更新了parser_trainer_test.sh。并按如下方式运行:

ubuntu@ubuntu-VirtualBox:~/models/syntaxnet$ syntaxnet/parser_trainer_test.sh

它给了我这个错误:

syntaxnet/parser_trainer_test.sh: line 36: /home/ubuntu/models/syntaxnet/syntaxnet/parser_trainer: No such file or directory

然后我将parser_trainer_test.sh第 35 行中的"$BINDIR/parser_trainer" 更新为 "$BINDIR/parser_trainer.py" 并再次运行它。

它给了我这个错误:

File "/home/ubuntu/models/syntaxnet/syntaxnet/parser_trainer.py", line 25,in <module>
from tensorflow.python.platform import tf_logging as logging
ImportError: cannot import name tf_logging

我浏览了 syntaxnet/tensorflow/python/platform 中的tf_logging.py和所有其他 python 文件我认为这就是错误所在。但如果你愿意,我可以发布更多。

parser.trainer.py :

import os
import os.path
import time
import tensorflow as tf
from tensorflow.python.platform import tf_logging as logging # this is where error happens
from tensorflow.python.platform import gfile

tf_logging.py:

import logging
import os
import sys
import time
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import WARN   

有些事情我很怀疑(如果它看起来很愚蠢,我不是很抱歉)。我在路径tensorflow/tensorflow/core/platform中找到了一个名为logging.h的文件,它定义了DEBUG,ERROR,FATAL,..,我感到困惑的是模型的目的是来自python的日志记录包还是这个logging.h文件。如果我错了,这可能是,请帮助我解决这个问题。

我怀疑问题是您正在尝试直接运行脚本,并且它希望由 Bazel 调用(以便正确设置环境、路径等)。请改为尝试以下命令:

$ bazel test //syntaxnet:parser_trainer_test

相关内容

最新更新