모듈을 임포트한다.
In [ ]:
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
print(tf.__version__)
In [22]:
#외부에서 n행 5열에 해당하는 데이터가 들어 온다.
x = tf.placeholder(tf.float32, shape=[None,5])
w = tf.Variable(tf.zeros([5,1]))
In [24]:
sess = tf.Session()
sess.run(tf.global_variables_initializer())
sess.run(w)
Out[24]:
In [47]:
#w2를 텐서플로에서 관리하는 변수로 선언 하겠다는 소리인가?
w2 = tf.Variable(tf.random_normal([3,1]))
In [49]:
sess.run(tf.global_variables_initializer())
sess.run(w2)
Out[49]:
In [51]:
sess.run(tf.zeros([5,5]))
Out[51]:
In [52]:
sess.run(tf.ones([5,5]))
Out[52]:
In [53]:
y = tf.matmul(x, w)
In [54]:
t = tf.placeholder(tf.float32, [None, 1])
loss = tf.reduce_sum(tf.square(y - t))