Python3 の tensorFlowでHelloWorldやってみます。

やる意味はそこまでじゃないのですが、基本中の基本ですかね

tensorFlowを使うには、まずセッション(Session())を作って、実行メソッド(run())に引数を渡す形で処理を行います


tensorHello.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import tensorflow as tf

# HelloWorld
hello = tf.constant('Hello World!')
sess = tf.Session()
print(sess.run(hello))


実行してみます
2行目にでているのは、CPUにあった最適なコンパイルがされてないよ という意味合いのものです
# python3.6 tensorHello.py
2018-05-18 03:37:16.381890: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2
b'Hello World'



以上です