• syntax的安装测试


    操作系统版本ubuntu1604
    1、安装vim编辑器:
        my@ubuntu:~$ sudo apt install  vim

    2、安装jdk8:
        my@ubuntu:~$ java

        my@ubuntu:~$ sudo add-apt-repository ppa:openjdk/ppa

        my@ubuntu:~$ sudo add-apt-repository ppa:openjdk-r/ppa
     
        my@ubuntu:~$ sudo apt-get update

        my@ubuntu:~$ sudo apt-get install openjdk-8-jdk

        my@ubuntu:~$ sudo apt-get install openjdk-8-jre openjdk-8-jdk-headlesss
        
        my@ubuntu:~$ java -version
    openjdk version "1.8.0_131"
    OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-2ubuntu1.16.04.3-b11)
    OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

    3、安装bazel:主要参考https://docs.bazel.build/versions/master/install.html

        my@ubuntu:~$ echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list

        my@ubuntu:~$ sudo apt install curl  

        my@ubuntu:~$ curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -

        my@ubuntu:~$ sudo apt-get update && sudo apt-get install bazel

        my@ubuntu:~$ sudo apt-get upgrade bazel

    4、安装tensorflow:

        my@ubuntu:~$ sudo apt-get install swig

        my@ubuntu:~$ sudo apt-get install python-pip python-dev

        my@ubuntu:~$ pip install --upgrade pip

        my@ubuntu:~$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

    安装完成后自己测试:

        $ python2.7
        >>> import tensorflow as tf
        >>> hello = tf.constant('Hello, TensorFlow!')
        >>> sess = tf.Session()
        >>> print(sess.run(hello))
        Hello, TensorFlow!
        >>> a = tf.constant(10)
        >>> b = tf.constant(32)
        >>> print(sess.run(a + b))
        42
        >>>
    返回命令行:ctrl + d


    5、安装virtualenv:
        my@ubuntu:~$ sudo apt-get install python-virtualenv

        在virtualenv中创建tensorfloe环境

        my@ubuntu:~$ virtualenv --system-site-packages ~/tensorflow

        激活tensorflow的virtualenv环境

        my@ubuntu:~$ source ~/tensorflow/bin/activate

    6、syntaxnet 配置

        注意现在是在tensorflow的virtualenv环境中安装tensorflow

        (tensorflow) my@ubuntu:~$ pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

        (tensorflow) my@ubuntu:~$ sudo apt install git

        (tensorflow) my@ubuntu:~$ git clone --recursive https://github.com/tensorflow/models.git

        (tensorflow) my@ubuntu:~$ cd models/syntaxnet/tensorflow

        (tensorflow) my@ubuntu:~/models/syntaxnet/tensorflow$ ./configure
        此处很有必要强调一下:冒号后为空的直接回车。
    Please specify the location of python. [Default is /home/my/tensorflow/bin/python]:
    Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]:
    Do you wish to use jemalloc as the malloc implementation? [Y/n] y
    jemalloc enabled
    Do you wish to build TensorFlow with Google Cloud Platform support? [y/N] n
    No Google Cloud Platform support will be enabled for TensorFlow
    Do you wish to build TensorFlow with Hadoop File System support? [y/N] n
    No Hadoop File System support will be enabled for TensorFlow
    Do you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N] n
    No XLA JIT support will be enabled for TensorFlow
    Found possible Python library paths:
      /home/my/tensorflow/lib/python2.7/site-packages
    Please input the desired Python library path to use.  Default is [/home/my/tensorflow/lib/python2.7/site-packages]

    Using python library path: /home/my/tensorflow/lib/python2.7/site-packages
    Do you wish to build TensorFlow with OpenCL support? [y/N] n
    No OpenCL support will be enabled for TensorFlow
    Do you wish to build TensorFlow with CUDA support? [y/N] n
    No CUDA support will be enabled for TensorFlow
    Configuration finished
    .........................
    INFO: Starting clean (this may take a while). Consider using --expunge_async if the clean takes more than several minutes.
    .........................


        (tensorflow) my@ubuntu:~/models/syntaxnet/tensorflow$ cd ..

        (tensorflow) my@ubuntu:~/models/syntaxnet$ bazel test syntaxnet/... util/utf8/...

        (tensorflow) my@ubuntu:~/models/syntaxnet$ chmod +x  syntaxnet/demo.sh

    7、pip安装 asciitree、mock

        (tensorflow) my@ubuntu:~/models/syntaxnet$  pip install asciitree

        (tensorflow) my@ubuntu:~/models/syntaxnet$ pip install mock


        测试一个句子:

        (tensorflow) my@ubuntu:~/models/syntaxnet$ sudo  echo 'Bob brought the pizza to Alice.' | syntaxnet/demo.sh


    2017-08-17 05:36:38.755334: W external/org_tensorflow/tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
    2017-08-17 05:36:38.755414: W external/org_tensorflow/tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
    2017-08-17 05:36:38.756685: W external/org_tensorflow/tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
    2017-08-17 05:36:38.756762: W external/org_tensorflow/tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
    2017-08-17 05:36:38.784232: I syntaxnet/term_frequency_map.cc:101] Loaded 46 terms from syntaxnet/models/parsey_mcparseface/label-map.
    2017-08-17 05:36:38.784650: I syntaxnet/term_frequency_map.cc:101] Loaded 46 terms from syntaxnet/models/parsey_mcparseface/label-map.
    2017-08-17 05:36:38.785159: I syntaxnet/embedding_feature_extractor.cc:35] Features: stack.child(1).label stack.child(1).sibling(-1).label stack.child(-1).label stack.child(-1).sibling(1).label stack.child(2).label stack.child(-2).label stack(1).child(1).label stack(1).child(1).sibling(-1).label stack(1).child(-1).label stack(1).child(-1).sibling(1).label stack(1).child(2).label stack(1).child(-2).label; input.token.tag input(1).token.tag input(2).token.tag input(3).token.tag stack.token.tag stack.child(1).token.tag stack.child(1).sibling(-1).token.tag stack.child(-1).token.tag stack.child(-1).sibling(1).token.tag stack.child(2).token.tag stack.child(-2).token.tag stack(1).token.tag stack(1).child(1).token.tag stack(1).child(1).sibling(-1).token.tag stack(1).child(-1).token.tag stack(1).child(-1).sibling(1).token.tag stack(1).child(2).token.tag stack(1).child(-2).token.tag stack(2).token.tag stack(3).token.tag; input.token.word input(1).token.word input(2).token.word input(3).token.word stack.token.word stack.child(1).token.word stack.child(1).sibling(-1).token.word stack.child(-1).token.word stack.child(-1).sibling(1).token.word stack.child(2).token.word stack.child(-2).token.word stack(1).token.word stack(1).child(1).token.word stack(1).child(1).sibling(-1).token.word stack(1).child(-1).token.word stack(1).child(-1).sibling(1).token.word stack(1).child(2).token.word stack(1).child(-2).token.word stack(2).token.word stack(3).token.word
    2017-08-17 05:36:38.785199: I syntaxnet/embedding_feature_extractor.cc:36] Embedding names: labels;tags;words
    2017-08-17 05:36:38.785212: I syntaxnet/embedding_feature_extractor.cc:37] Embedding dims: 32;32;64
    2017-08-17 05:36:38.785503: I syntaxnet/embedding_feature_extractor.cc:35] Features: input.digit input.hyphen; input.prefix(length="2") input(1).prefix(length="2") input(2).prefix(length="2") input(3).prefix(length="2") input(-1).prefix(length="2") input(-2).prefix(length="2") input(-3).prefix(length="2") input(-4).prefix(length="2"); input.prefix(length="3") input(1).prefix(length="3") input(2).prefix(length="3") input(3).prefix(length="3") input(-1).prefix(length="3") input(-2).prefix(length="3") input(-3).prefix(length="3") input(-4).prefix(length="3"); input.suffix(length="2") input(1).suffix(length="2") input(2).suffix(length="2") input(3).suffix(length="2") input(-1).suffix(length="2") input(-2).suffix(length="2") input(-3).suffix(length="2") input(-4).suffix(length="2"); input.suffix(length="3") input(1).suffix(length="3") input(2).suffix(length="3") input(3).suffix(length="3") input(-1).suffix(length="3") input(-2).suffix(length="3") input(-3).suffix(length="3") input(-4).suffix(length="3"); input.token.word input(1).token.word input(2).token.word input(3).token.word input(-1).token.word input(-2).token.word input(-3).token.word input(-4).token.word
    2017-08-17 05:36:38.785558: I syntaxnet/embedding_feature_extractor.cc:36] Embedding names: other;prefix2;prefix3;suffix2;suffix3;words
    2017-08-17 05:36:38.785589: I syntaxnet/embedding_feature_extractor.cc:37] Embedding dims: 8;16;16;16;16;64
    2017-08-17 05:36:38.790922: I syntaxnet/term_frequency_map.cc:101] Loaded 49 terms from syntaxnet/models/parsey_mcparseface/tag-map.
    2017-08-17 05:36:39.141329: W external/org_tensorflow/tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
    2017-08-17 05:36:39.141451: W external/org_tensorflow/tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
    2017-08-17 05:36:41.133684: I syntaxnet/term_frequency_map.cc:101] Loaded 64036 terms from syntaxnet/models/parsey_mcparseface/word-map.
    2017-08-17 05:36:41.140511: I syntaxnet/term_frequency_map.cc:101] Loaded 64036 terms from syntaxnet/models/parsey_mcparseface/word-map.
    2017-08-17 05:36:41.142281: I syntaxnet/term_frequency_map.cc:101] Loaded 49 terms from syntaxnet/models/parsey_mcparseface/tag-map.
    INFO:tensorflow:Building training network with parameters: feature_sizes: [12 20 20] domain_sizes: [   49    51 64038]
    INFO:tensorflow:Building training network with parameters: feature_sizes: [2 8 8 8 8 8] domain_sizes: [    5 10665 10665  8970  8970 64038]
    INFO:tensorflow:Restoring parameters from syntaxnet/models/parsey_mcparseface/parser-params
    INFO:tensorflow:Restoring parameters from syntaxnet/models/parsey_mcparseface/tagger-params
    2017-08-17 05:36:43.152605: I syntaxnet/term_frequency_map.cc:101] Loaded 46 terms from syntaxnet/models/parsey_mcparseface/label-map.
    2017-08-17 05:36:43.152742: I syntaxnet/embedding_feature_extractor.cc:35] Features: stack.child(1).label stack.child(1).sibling(-1).label stack.child(-1).label stack.child(-1).sibling(1).label stack.child(2).label stack.child(-2).label stack(1).child(1).label stack(1).child(1).sibling(-1).label stack(1).child(-1).label stack(1).child(-1).sibling(1).label stack(1).child(2).label stack(1).child(-2).label; input.token.tag input(1).token.tag input(2).token.tag input(3).token.tag stack.token.tag stack.child(1).token.tag stack.child(1).sibling(-1).token.tag stack.child(-1).token.tag stack.child(-1).sibling(1).token.tag stack.child(2).token.tag stack.child(-2).token.tag stack(1).token.tag stack(1).child(1).token.tag stack(1).child(1).sibling(-1).token.tag stack(1).child(-1).token.tag stack(1).child(-1).sibling(1).token.tag stack(1).child(2).token.tag stack(1).child(-2).token.tag stack(2).token.tag stack(3).token.tag; input.token.word input(1).token.word input(2).token.word input(3).token.word stack.token.word stack.child(1).token.word stack.child(1).sibling(-1).token.word stack.child(-1).token.word stack.child(-1).sibling(1).token.word stack.child(2).token.word stack.child(-2).token.word stack(1).token.word stack(1).child(1).token.word stack(1).child(1).sibling(-1).token.word stack(1).child(-1).token.word stack(1).child(-1).sibling(1).token.word stack(1).child(2).token.word stack(1).child(-2).token.word stack(2).token.word stack(3).token.word
    2017-08-17 05:36:43.152789: I syntaxnet/embedding_feature_extractor.cc:36] Embedding names: labels;tags;words
    2017-08-17 05:36:43.152802: I syntaxnet/embedding_feature_extractor.cc:37] Embedding dims: 32;32;64
    2017-08-17 05:36:43.155646: I syntaxnet/term_frequency_map.cc:101] Loaded 49 terms from syntaxnet/models/parsey_mcparseface/tag-map.
    2017-08-17 05:36:43.328797: I syntaxnet/term_frequency_map.cc:101] Loaded 49 terms from syntaxnet/models/parsey_mcparseface/tag-map.
    2017-08-17 05:36:43.331044: I syntaxnet/term_frequency_map.cc:101] Loaded 46 terms from syntaxnet/models/parsey_mcparseface/label-map.
    2017-08-17 05:36:43.331196: I syntaxnet/embedding_feature_extractor.cc:35] Features: input.digit input.hyphen; input.prefix(length="2") input(1).prefix(length="2") input(2).prefix(length="2") input(3).prefix(length="2") input(-1).prefix(length="2") input(-2).prefix(length="2") input(-3).prefix(length="2") input(-4).prefix(length="2"); input.prefix(length="3") input(1).prefix(length="3") input(2).prefix(length="3") input(3).prefix(length="3") input(-1).prefix(length="3") input(-2).prefix(length="3") input(-3).prefix(length="3") input(-4).prefix(length="3"); input.suffix(length="2") input(1).suffix(length="2") input(2).suffix(length="2") input(3).suffix(length="2") input(-1).suffix(length="2") input(-2).suffix(length="2") input(-3).suffix(length="2") input(-4).suffix(length="2"); input.suffix(length="3") input(1).suffix(length="3") input(2).suffix(length="3") input(3).suffix(length="3") input(-1).suffix(length="3") input(-2).suffix(length="3") input(-3).suffix(length="3") input(-4).suffix(length="3"); input.token.word input(1).token.word input(2).token.word input(3).token.word input(-1).token.word input(-2).token.word input(-3).token.word input(-4).token.word
    2017-08-17 05:36:43.331254: I syntaxnet/embedding_feature_extractor.cc:36] Embedding names: other;prefix2;prefix3;suffix2;suffix3;words
    2017-08-17 05:36:43.331277: I syntaxnet/embedding_feature_extractor.cc:37] Embedding dims: 8;16;16;16;16;64
    2017-08-17 05:36:45.140765: I syntaxnet/term_frequency_map.cc:101] Loaded 64036 terms from syntaxnet/models/parsey_mcparseface/word-map.
    2017-08-17 05:36:45.592410: I syntaxnet/term_frequency_map.cc:101] Loaded 64036 terms from syntaxnet/models/parsey_mcparseface/word-map.
    INFO:tensorflow:Processed 1 documents
    INFO:tensorflow:Total processed documents: 1
    INFO:tensorflow:num correct tokens: 0
    INFO:tensorflow:total tokens: 7
    INFO:tensorflow:Seconds elapsed in evaluation: 2.38, eval metric: 0.00%
    INFO:tensorflow:Processed 1 documents
    INFO:tensorflow:Total processed documents: 1
    INFO:tensorflow:num correct tokens: 1
    INFO:tensorflow:total tokens: 6
    INFO:tensorflow:Seconds elapsed in evaluation: 2.77, eval metric: 16.67%
    INFO:tensorflow:Read 1 documents
    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

    注意自己测试时的路径:我重启vm后的又测试了一个先要激活tensorflow环境:

        source ~/tensorflow/bin/activate

    然后cd到demo.sh的上一级目录:

        (tensorflow) my@ubuntu:~/models/syntaxnet$ sudo  echo 'I love my dog.' | syntaxnet/demo.sh



        安装总结:以上是在vm虚拟机上安装的一个ubuntu系统,刚开始在centos7.3上安装多次失败,官方的文档也是在ubuntu上安装的。上面的安装文档也纠正了很多错误,
    参考地址:http://blog.csdn.net/u012507864/article/details/51478060,但完全按照这个地址我也没有安装成功。我写得这个文档是安装了六遍七遍后的一个经验。











        

        

        
        


  • 相关阅读:
    CF1435E Solo mid Oracle(推柿子)
    CF1435C Perform Easily(Set)
    NC7501I (反向建图)
    NC7501D Router Mesh (去掉割点算连通快的变化)
    超全的Python第三方库
    字符串常见题目
    IDEA的常用设置大全
    IDEA的介绍与安装
    涨姿势啦(1)
    Torch常用的函数总结
  • 原文地址:https://www.cnblogs.com/herosoft/p/8134113.html
Copyright © 2020-2023  润新知