首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SyntaxNet:没有名为模拟的模块

SyntaxNet:没有名为模拟的模块
EN

Stack Overflow用户
提问于 2017-03-15 08:05:44
回答 1查看 1.3K关注 0票数 1

我遵循了在我的MacOSXSiera10.12.3中安装SyntaxNet 这里的说明。

我安装了所有所需的软件:

  • python 2.7
  • 巴泽尔(通过brew install bazel)
  • (通过brew install swig)
  • 协议缓冲区(通过pip install -U protobuf==3.0.0b2)
  • 模拟(通过pip install mock)
  • asciitree (通过pip install asciitree)
  • numpy (通过pip install numpy)

然后构建和测试SyntaxNet:

代码语言:javascript
复制
git clone --recursive https://github.com/tensorflow/models.git
cd models/syntaxnet/tensorflow
./configure
cd ..
bazel test --linkopt=-headerpad_max_install_names \
  syntaxnet/... util/utf8/...

在这个过程中,这6个测试失败了(就像其他用户在Github问题列表中评论的那样)。由于这是预期的行为,我继续运行第一个演示:

代码语言:javascript
复制
echo 'Bob brought the pizza to Alice.' | syntaxnet/demo.sh

预期结果:

代码语言:javascript
复制
Input: Bob brought the pizza to Alice .
Parse:
brought VBD ROOT
 +-- Bob NNP nsubj
 +-- pizza NN dobj
 |   +-- the DT det
 +-- to IN prep
 |   +-- Alice NNP pobj
 +-- . . punct

但发生了以下错误:

代码语言:javascript
复制
Traceback (most recent call last):
  File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/conll2tree.runfiles/__main__/syntaxnet/conll2tree.py", line 20, in <module>
    import asciitree
ImportError: No module named asciitree
Traceback (most recent call last):
  File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/__main__/syntaxnet/parser_eval.py", line 23, in <module>
    import tensorflow as tf
  File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/org_tensorflow/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 124, in <module>
    from tensorflow.python.platform import test
  File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/org_tensorflow/tensorflow/python/platform/test.py", line 50, in <module>
    import mock                # pylint: disable=g-import-not-at-top,unused-import
ImportError: No module named mock
Traceback (most recent call last):
  File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/__main__/syntaxnet/parser_eval.py", line 23, in <module>
    import tensorflow as tf
  File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/org_tensorflow/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 124, in <module>
    from tensorflow.python.platform import test
  File "/Users/MyUserName/SyntaxNet/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/org_tensorflow/tensorflow/python/platform/test.py", line 50, in <module>
    import mock                # pylint: disable=g-import-not-at-top,unused-import
ImportError: No module named mock

demo.sh的内容如下:

代码语言:javascript
复制
#!/bin/bash
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

# A script that runs a tokenizer, a part-of-speech tagger and a dependency
# parser on an English text file, with one sentence per line.
#
# Example usage:
#  echo "Parsey McParseface is my favorite parser!" | syntaxnet/demo.sh

# To run on a conll formatted file, add the --conll command line argument.
#

PARSER_EVAL=bazel-bin/syntaxnet/parser_eval
MODEL_DIR=syntaxnet/models/parsey_mcparseface
[[ "$1" == "--conll" ]] && INPUT_FORMAT=stdin-conll || INPUT_FORMAT=stdin

$PARSER_EVAL \
  --input=$INPUT_FORMAT \
  --output=stdout-conll \
  --hidden_layer_sizes=64 \
  --arg_prefix=brain_tagger \
  --graph_builder=structured \
  --task_context=$MODEL_DIR/context.pbtxt \
  --model_path=$MODEL_DIR/tagger-params \
  --slim_model \
  --batch_size=1024 \
  --alsologtostderr \
   | \
  $PARSER_EVAL \
  --input=stdin-conll \
  --output=stdout-conll \
  --hidden_layer_sizes=512,512 \
  --arg_prefix=brain_parser \
  --graph_builder=structured \
  --task_context=$MODEL_DIR/context.pbtxt \
  --model_path=$MODEL_DIR/parser-params \
  --slim_model \
  --batch_size=1024 \
  --alsologtostderr \
  | \
  bazel-bin/syntaxnet/conll2tree \
  --task_context=$MODEL_DIR/context.pbtxt \
  --alsologtostderr

更新 sudo pip freezepip freeze返回相同的内容:

代码语言:javascript
复制
appdirs==1.4.3
asciitree==0.3.3
mock==2.0.0
numpy==1.12.0
packaging==16.8
pbr==2.0.0
protobuf==3.0.0b2
pyparsing==2.2.0
pyserial==3.2.1
six==1.10.0
tensorflow==1.0.1
tensorflow-gpu==1.0.1
EN

回答 1

Stack Overflow用户

发布于 2017-03-16 03:11:09

试着:

sudo pip安装--忽略-安装了asciitree

sudo pip安装--忽略-已安装模拟

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42804103

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档