1
我用TensorFlow創建了一個簡單的卷積神經元網絡。 當我使用邊緣= 32px的輸入圖像時,網絡工作正常,但是如果我將邊緣兩次增加到64px,那麼熵反演就像NaN一樣。問題是如何解決這個問題?NaN的Tensorflow熵在訓練時的大輸入CNN
CNN結構非常簡單,看起來像: 輸入 - > conv-> pool2-> conv-> pool2-> conv-> pool2-> FC-> SOFTMAX
熵計算,如:
prediction = tf.nn.softmax(tf.matmul(h_fc1_drop, W_fc2) + b_fc2)
cross_entropy = tf.reduce_mean(-tf.reduce_sum(ys * tf.log(prediction), reduction_indices=[1])) # loss
train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)
train_pred = tf.equal(tf.argmax(prediction, 1), tf.argmax(ys, 1))
train_accuracy = tf.reduce_mean(tf.cast(train_pred, tf.float32))
爲64PX我:
train_accuracy=0.09000000357627869, cross_entropy=nan, test_accuracy=0.1428571492433548
train_accuracy=0.2800000011920929, cross_entropy=nan, test_accuracy=0.1428571492433548
train_accuracy=0.27000001072883606, cross_entropy=nan, test_accuracy=0.1428571492433548
爲32PX它看起來很好,訓練給出結果:
train_accuracy=0.07999999821186066, cross_entropy=20.63970184326172, test_accuracy=0.15000000596046448
train_accuracy=0.18000000715255737, cross_entropy=15.00744342803955, test_accuracy=0.1428571492433548
train_accuracy=0.18000000715255737, cross_entropy=12.469900131225586, test_accuracy=0.13571429252624512
train_accuracy=0.23000000417232513, cross_entropy=10.289153099060059, test_accuracy=0.11428571492433548
非常感謝,你是對的,噪音有幫助。 – Verych