私はTensorboardで単純な線形回帰を視覚化しようとしています。以下はコードです。しかし、私がコンソールで見ている値は、テンソルボードのグラフに示されている値とまったく同じではありません。私は解釈することができていますがMSEの値である 異なる平均二乗値を示すテンソルボード
Epoch 100 MSE 2.42409
Epoch 200 MSE 2.28097
Epoch 300 MSE 2.14192
Epoch 400 MSE 2.00997
Epoch 500 MSE 1.88537
Epoch 600 MSE 1.76792
Epoch 700 MSE 1.65733
Epoch 800 MSE 1.55331
Epoch 900 MSE 1.45556
model saved at step= 167832
と実行のためのtensorboardスカラープロットされる:コンソールで
tf.reset_default_graph()
X = tf.placeholder(dtype=tf.float32, shape=(None, n+1), name="X")
y = tf.placeholder(dtype=tf.float32, shape=(None, 1), name="y")
theta = tf.Variable(tf.random_uniform([n+1, batch_size], -1.0, 1.0), name="theta")
global_step = tf.Variable(0,name='global_step',trainable=False)
y_pred = tf.matmul(X, theta, name="predictions")
error = y_pred - y
mse = tf.reduce_mean(tf.square(error), name='mse')
optimizer = tf.train.AdadeltaOptimizer(learning_rate=learning_rate)
training_op = optimizer.minimize(mse, global_step=global_step)
mse_summary = tf.summary.scalar('MSE', mse)
summary_op = tf.summary.merge_all()
file_writer = tf.summary.FileWriter(logdir, tf.get_default_graph())
init = tf.group(tf.global_variables_initializer(), tf.local_variables_initializer())
saver = tf.train.Saver()
with tf.Session() as sess:
sess.run(init)
for epoch in range(1, n_epochs):
for batch_index in range(n_batches):
X_batch, y_batch= fetch_batch(epoch, batch_index, batch_size)
if batch_index % 50 == 0 and batch_index != 0:
_,summary_str = sess.run([training_op, summary_op],feed_dict={X:X_batch, y:y_batch})
file_writer.add_summary(summary_str, global_step=tf.train.global_step(sess, global_step))
sess.run(training_op, feed_dict={X:X_batch, y:y_batch})
if epoch % 100 == 0:
print("Epoch", epoch, "MSE", sess.run(mse, feed_dict={X:X_batch, y:y_batch})
best_theta = theta.eval()
file_writer.close()
、私は以下のメッセージを取得しています6. *〜4. *の範囲です。あるいは、私は視覚化に何かを見逃しているかもしれません。私は、最後のエポック、すなわち1.4または100エポック2.42でさえ、mseに近いところでカーブを見ることができません。
助けてください。前もって感謝します。