1
코드 1에서 init = tf.global_variables_initializer()를 사용하고 코드 2에서 사용하지 않은 이유는 무엇입니까?Tensor Flow의 global_variables_initializer()
코드 1 :
import numpy as np
import tensorflow as tf
y_hat = tf.constant(36, name='y_hat')
y = tf.constant(39, name='y')
loss = tf.Variable((y - y_hat)**2, name='loss')
init = tf.global_variables_initializer()
with tf.Session() as session:
session.run(init)
print(session.run(loss))
코드 2 :
a = tf.constant(2)
b = tf.constant(10)
c = tf.multiply(a,b)
sess = tf.Session()
print(sess.run(c))