1

我按照在我的 Mac OS X Sierra 10.12.3 中安装 SyntaxNet 的说明进行操作

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

  • 蟒蛇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:

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 问题列表中评论的那样)。由于这是预期的行为,我继续运行第一个演示:

echo 'Bob brought the pizza to Alice.' | syntaxnet/demo.sh

预期结果:

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

但是出现了以下错误:

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如下:

#!/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返回相同的东西:

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
4

1 回答 1

3

试试:</p>

sudo pip install --ignore-installed asciitree

sudo pip install --ignore-installed mock

于 2017-03-16T03:11:09.860 回答