WindowsにTensorflowをインストールする

1936 ワード

1,TensorFlowは64ビットプラットフォームのみをサポート
2、python 3.5をダウンロードします.X(64ビットでなければなりません)のアドレスは次のとおりです.
https://www.python.org/ftp/python/3.5.2/python-3.5.2-amd64.exe
https://www.python.org/ftp/python/3.5.2/python-3.5.2-embed-amd64.zip

3 pythonをインストールし、pythonとpipを検証します.
C:\Users\Administrator>python -V
Python 3.5.2

C:\Users\Administrator>pip3 -V
pip3 8.1.1 from d:\program files\python35\lib\site-packages (python 3.5)

4,TensorFlow(only cpu)のインストール
pip3 install --upgrade tensorflow

5,TensorFlowのhello world
C:\Users\Administrator>python

Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

>>> import tensorflow as tf
>>> hello = tf.constant('Hello tensorflow1')
>>> session = tf.Session()
>>> print(session.run(hello))

b'Hello tensorflow1'

    b'Hello tensorflow1'   TensorFlow      .

6、もしあなたがjava開発なら、java APIを試してみたいかもしれませんが、結果はがっかりします.遅すぎます.世界の終わりです.コードは以下のように、自分で楽しんでください.
public String tf() throws Exception{
    final String value = "Hello tensorflow version :  "  + TensorFlow.version();

    System.out.println(value);

    //     tensor
    Tensor tensor = Tensor.create(value.getBytes("UTF-8"));

    //       
    Graph graph = new Graph();
    graph.opBuilder("Const","myConst").setAttr("dtype",tensor.dataType())
            .setAttr("value",tensor).build();
    //    Session
    Session session = new Session(graph);
    graph.close();
    //      
    Tensor result = session.runner().fetch("myConst").run().get(0);
    System.out.println(result);
    return new String(result.bytesValue(),"UTF-8");
}