3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

TensorFlowの定数を使って1 + 1の計算をやってみた

3
Last updated at Posted at 2018-11-21

計算に必要なもの

定数

はじめに定義したら値の変更ができない
tf.constantで定義する

セッション

実際の計算結果を得るためにはtf.Sessionクラスのインスタンスが必要
生成したセッションのrunメソッドに計算したいノードを指定して実行する

実際の計算例

実際にTensorFlowを使い、簡単な計算

x = 1
y = 1
z = x + y
z = 2(出力)

を実行してみます

1. Tensorflowライブラリのインポート

import tensorflow as tf

2. 定数の定義

x = constant(1, name='x')
y = constant(1, name='y')
z = x + y 

3. 計算を実行

with tf.Session() as sess:
      print(sess.run(z))

出力結果

2

1 + 1が計算されていることを確認

3
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?