我正在嘗試使用 tf.scatter_add 在 tensorflow 中實現(xiàn) unpool,但我遇到了一個奇怪的錯誤,這是我的代碼:import tensorflow as tfimport numpy as npimport randomtf.reset_default_graph()mat = list(range(64))random.shuffle(mat)mat = np.array(mat)mat = np.reshape(mat, [1,8,8,1])M = tf.constant(mat, dtype=tf.float32)pool1, argmax1 = tf.nn.max_pool_with_argmax(M, ksize=[1,2,2,1], strides=[1,2,2,1], padding='SAME')pool2, argmax2 = tf.nn.max_pool_with_argmax(pool1, ksize=[1,2,2,1], strides=[1,2,2,1], padding='SAME')pool3, argmax3 = tf.nn.max_pool_with_argmax(pool2, ksize=[1,2,2,1], strides=[1,2,2,1], padding='SAME')輸出:[[ 0. 0.] [ 0. 63.]][[ 0. 0. 0. 0.] [ 0. 0. 0. 0.] [ 0. 0. 126. 0.] [ 0. 0. 0. 0.]][[ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 315. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0. 0. 0. 0.]]位置是對的,但價值是錯誤的。unpool2 是對的,unpool1 是期望值的兩倍,unpool2 是期望值的五倍。我不知道怎么了,誰能告訴我如何修復(fù)這個錯誤?
添加回答
舉報
0/150
提交
取消