私は何かが明らかでないと確信しています。ここに私のコードの末尾です:シンプルネットを訓練すると、変数の値が2回以上変更されないようです。
# simple loss function
loss = tf.reduce_sum(tf.abs(tf.sub(x4, yn)))
train_step = tf.train.GradientDescentOptimizer(0.000001).minimize(loss)
with tf.Session() as sess:
tf.initialize_all_variables().run()
print(sess.run([tf.reduce_sum(w1), tf.reduce_sum(b1)]))
for i in range(5):
# fill in x1 and yn
sess.run(train_step, feed_dict={x1: in_images, yn: out_images})
print(sess.run([tf.reduce_sum(w1), tf.reduce_sum(b1)]))
損失関数から下降ネットワークはconv2d年代とbias_adds、およびELU年代で、シンプルCNNあります。最初のレイヤーの重みと偏りがどのように変化するかを見てみたかったのです。最初のprintは、w1がランダム法線で初期化され、b1がゼロで初期化されるので、期待値([+/- 100 or so、0])を返します。
2番目のprintステートメントは、期待どおりに異なる値のペアを示します。
ループ内の変数の値を更新するのではなく、loop_stepの各呼び出しが毎回同じことをしているかのように、ループを通過するたびに、2番目のprint文が同じ値のペアを出力することが期待されますネットワーク。
私はここで何が欠けていますか?ここで
が実行の興味深い部分のカット&ペーストです:必要に応じて
I tensorflow/core/common_runtime/gpu/gpu_device.cc:806] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 970, pci bus id: 0000:01:00.0)
[-50.281082, 0.0]
W tensorflow/core/common_runtime/bfc_allocator.cc:213] Ran out of memory trying to allocate 3.98GiB. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory is available.
[112.52832, 0.078026593]
[112.52832, 0.078026593]
[112.52832, 0.078026593]
[112.52832, 0.078026593]
[112.52832, 0.078026593]
私は、ネットワーク自体を投稿することができますが、私はこの問題は、どのようにtensorflowアップデート状態の私の精神的なモデルであると思います。
ここでは全体のpythonプログラムは、問題を示すために、画像入力のためのダミールーチンで、です:私は他の訓練例の束を見てきました
import tensorflow as tf
import numpy as np
from scipy import misc
H = 128
W = 128
x1 = tf.placeholder(tf.float32, [None, H, W, 1], "input_image")
yn = tf.placeholder(tf.float32, [None, H-12, W-12, 1], "test_image")
w1 = tf.Variable(tf.random_normal([7, 7, 1, 64])) # 7x7, 1 input chan, 64 output chans
b1 = tf.Variable(tf.constant(0.1, shape=[64]))
x2 = tf.nn.conv2d(x1, w1, [1,1,1,1], "VALID")
x2 = tf.nn.bias_add(x2, b1)
x2 = tf.nn.elu(x2)
w2 = tf.Variable(tf.random_normal([5, 5, 64, 32])) # 5x5, 64 input 32 output chans
b2 = tf.Variable(tf.constant(0.1, shape=[32]))
x3 = tf.nn.conv2d(x2, w2, [1,1,1,1], "VALID")
x3 = tf.nn.bias_add(x3, b2)
x3 = tf.nn.elu(x3)
w3 = tf.Variable(tf.random_normal([3, 3, 32, 1]))
b3 = tf.Variable(tf.constant(0.1, shape=[1]))
x4 = tf.nn.conv2d(x3, w3, [1,1,1,1], "VALID")
x4 = tf.nn.bias_add(x4, b3)
x4 = tf.nn.elu(x4)
loss = tf.reduce_sum(tf.abs(tf.sub(x4, yn)))
train_step = tf.train.GradientDescentOptimizer(0.001).minimize(loss)
# fake for testing
in_images = np.random.rand(20, 128, 128, 1)
out_images = np.random.rand(20, 116, 116, 1)
with tf.Session() as sess:
tf.initialize_all_variables().run()
print(sess.run([tf.reduce_mean(w1), tf.reduce_mean(b1)]))
for i in range(5):
# fill in x1 and yn
sess.run(train_step, feed_dict={x1: in_images, yn: out_images})
print(sess.run([tf.reduce_mean(w1), tf.reduce_mean(b1)]))
と私はまだいませんよ私が間違っていることを見ている。学習率を変更するだけで印刷される数値は変わりますが、振る舞いは変わらず、オプティマイザを実行しても明らかな変化はありません。
なぜこの超小型学習率は0.000001ですか?トレーニングは最初のステップの後にちょうど立ち往生しているのでしょうか? – lballes
結果は学習率に関係なく同じです。 .01〜.000001の範囲で料金を試しました。 – user28839
( "同じ"とは行動が同じです - 値の変更だけです。数字は学習率によって異なります) – user28839