本文介绍了从 parser_trainer_test.sh 训练 SyntaxNet(导入错误:无法导入名称 tf_logging)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am new to python and SyntaxNet and I am trying to train SyntaxNet from SyntaxNet Tutorial.To trained the model I updated parser_trainer_test.sh based on The Tutorial. and ran it as follow:

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

然后我在 到 "$BINDIR/parser_trainer.py" \ 并再次运行.

Then I updated "$BINDIR/parser_trainer" \ in line 35 of parser_trainer_test.sh to "$BINDIR/parser_trainer.py" \ and ran it again.

它给了我这个错误:

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/中浏览了 tf_logging.py 和所有其他 python 文件张量流/蟒蛇/平台我认为这就是错误所在.但如果你愿意,我可以发布更多.

I went through tf_logging.py and all other python files in syntaxnet/tensorflow/python/platform I think that's where the error is. But if you want, I can post more.

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   

有些事情我很怀疑(我不是专业人士,如果看起来很傻,我很抱歉).我在路径 logging.h 的文件"nofollow">tensorflow/tensorflow/core/platform 定义了 DEBUG,ERROR,FATAL,.. 我很困惑模型的目标是来自 python 的日志包还是这个logging.h 文件.如果我错了,这很可能,请帮助我解决这个问题.

There is something that I am suspecious about (I am not perofessional so sorry if it seems silly). I found a file named logging.hin path tensorflow/tensorflow/core/platform which defines DEBUG,ERROR,FATAL,.. and I get confused whether the aim of the model is the logging package from python or this logging.h file. If am wrong, which is probable, please help me through this problem.

推荐答案

我怀疑问题是你试图直接运行脚本,并且它期望被 Bazel 调用(这样环境、路径等就不会被调用).适当设置).请尝试使用以下命令:

I suspect the problem is that you are trying to run the script directly, and it expects to be invoked by Bazel (so that the environment, paths, etc. are set up appropriately). Try the following command instead:

$ bazel test //syntaxnet:parser_trainer_test

这篇关于从 parser_trainer_test.sh 训练 SyntaxNet(导入错误:无法导入名称 tf_logging)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 03:39