training SyntaxNet from parser_trainer_test.sh (ImportError: cannot import name tf_logging)

半城伤御伤魂 提交于 2019-12-13 05:50:36

问题


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

It gave me this error:

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

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

And it gave me this error:

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

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   

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.


回答1:


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


来源:https://stackoverflow.com/questions/37576159/training-syntaxnet-from-parser-trainer-test-sh-importerror-cannot-import-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!