私は以下のコードを私に説明する助けが必要です。私はTensorFlowに新しいのようなものだけど、私は変数を表し、X、B、Wとyを何TensorFlowコードヘルプ - 入門例
import tensorflow as tf
# Model parameters
#Why are variables initialize with .3 and -.3
W = tf.Variable([.3], dtype=tf.float32)
b = tf.Variable([-.3], dtype=tf.float32)
の下のコード内で定義された具体的な質問がありますか?
# Model input and output
x = tf.placeholder(tf.float32) # this is the input
linear_model = W * x + b # this is the linear_model operation
y = tf.placeholder(tf.float32) # Is this the output we're trying to predict.
0.01のパラメータ値を渡すコードがGradientDescentOptimizer関数に渡されるのはなぜですか?
# loss - measure how far apart the current model is from the provided data.
loss = tf.reduce_sum(tf.square(linear_model - y)) # sum of the squares
# optimizer
optimizer = tf.train.GradientDescentOptimizer(0.01) # Why are we passing the value '0.01'
train = optimizer.minimize(loss)
ここにy_trainは何を表していますか?
# training data
x_train = [1, 2, 3, 4] # the input variables we know
y_train = [0, -1, -2, -3] #
# training loop
init = tf.global_variables_initializer() # init is a handle to the TensorFlow sub-graph that initializes all the global variables. Until we call sess.run, the variables are unitialized
sess = tf.Session() # Sesson encapsulates the control and state of the TensorFlow runtime. ITs used to evaluate the nodes, we must run the computational graph within a session
sess.run(init) # reset values to wrong
for i in range(1000):
sess.run(train, {x: x_train, y: y_train})
ここで、変数curr_W、curr_bはどのような意味を表しますか?
# evaluate training accuracy
# Why does the variables W and b represent?
curr_W, curr_b, curr_loss = sess.run([W, b, loss], {x: x_train, y: y_train})
print("W: %s b: %s loss: %s"%(curr_W, curr_b, curr_loss))
のコード例では、Tensorflowのウェブサイトから来ている:https://www.tensorflow.org/get_started/get_started#complete_program
私のコード例の偏りと重みの値は何ですか? –
'W'と' b'の初期値は0.3と-0.3です。答えに記載されているように、それほど重要ではありません。その後、訓練中、これらの値は常に変化します(良い練習 - 各反復でそれらを印刷します)。最後に、-1と1に近づくまでです。 – Maxim