LoginSignup
1
3

More than 5 years have passed since last update.

TensorFlowのメモ

Posted at

<モデルの定義>
1.まずライブラリを呼び出す。
import tensorflow as tf
で読み込む。

2.モデル構築
定数を定義する場合には、
tf.constant(定数, name='定数の名前')

初期値のある変数を定義する場合には、
tf.Variable(初期値, name='変数の名前')
で定義する。

初期値がないものの、最初に型と形を決めておく時は、
tf.placeholder(型(tf.init32など), name="名前")

変数に値を入れる場合(下記の例では、xにaを代入する場合)には、
tf.assign(x, a)

すべての変数を初期化(モデルを構築した後に実施):
tf.global_variables_iniializer()

加算
tf.add(x, y)
乗算
tf.multiply(x, y)

<実行フェーズ>
変数の初期化

with tf.Session() as sess:
sess.run(init)

tf.placeholderに対して、値をfeedしてやる場合。
sess.run(x, feed_dict={y, a})

placeholderのキーyに対してaをフィード。placeholderが呼ばれる演算がx

※上記内容はあくまでメモであり、正確性を欠いている可能性がありますので、ご注意ください。

 

1
3
0

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
1
3