在做图像低曝光增强时,Learning to See in the Dark这篇文章能够达到较好的效果,如下图,网络能够很好的展示文章的逻辑,文章的其他部分比较好理解,有不理解之处可以做探讨.
在网络中,为了节省上采样时间,作者用了pixel shuffle功能, depth_to_space函数,函数的意思比较抽象,难于理解,下面通过简单程序表明,网络最后的feature map(1*4*4*12),是如何变形为rgb输出(1*8*8*3)的,tensorflow的格式为NHWC.
python程序如下:
import tensorflow as tf
x = tf.range(192) #1*4*4*12
x = tf.reshape(x, [1, 4, 4, 12])
y = tf.depth_to_space(x, 2)
with tf.Session() as sess:
z = sess.run(x)
print z
z = sess.run(y)
print z
输入depth_to_space的feature map为,其中每一列数字,为feature map的一个channel上的所有元素, 行主序:
[[[[ 0 1 2 3 4 5 6 7 8 9 10 11]
[ 12 13 14 15 16 17 18 19 20 21 22 23]
[ 24 25 26 27 28 29 30 31 32 33 34 35]
[ 36 37 38 39 40 41 42 43 44 45 46 47]]
[[ 48 49 50 51 52 53 54 55 56 57 58 59]
[ 60 61 62 63 64 65 66 67 68 69 70 71]
[ 72 73 74 75 76 77 78 79 80 81 82 83]
[ 84 85 86 87 88 89 90 91 92 93 94 95]]
[[ 96 97 98 99 100 101 102 103 104 105 106 107]
[108 109 110 111 112 113 114 115 116 117 118 119]
[120 121 122 123 124 125 126 127 128 129 130 131]
[132 133 134 135 136 137 138 139 140 141 142 143]]
[[144 145 146 147 148 149 150 151 152 153 154 155]
[156 157 158 159 160 161 162 163 164 165 166 167]
[168 169 170 171 172 173 174 175 176 177 178 179]
[180 181 182 183 184 185 186 187 188 189 190 191]]]]
输出feature map (RGB)为,可以对照着数字序号理解一下:
[[[[ 0 1 2]
[ 3 4 5]
[ 12 13 14]
[ 15 16 17]
[ 24 25 26]
[ 27 28 29]
[ 36 37 38]
[ 39 40 41]]
[[ 6 7 8]
[ 9 10 11]
[ 18 19 20]
[ 21 22 23]
[ 30 31 32]
[ 33 34 35]
[ 42 43 44]
[ 45 46 47]]
[[ 48 49 50]
[ 51 52 53]
[ 60 61 62]
[ 63 64 65]
[ 72 73 74]
[ 75 76 77]
[ 84 85 86]
[ 87 88 89]]
[[ 54 55 56]
[ 57 58 59]
[ 66 67 68]
[ 69 70 71]
[ 78 79 80]
[ 81 82 83]
[ 90 91 92]
[ 93 94 95]]
[[ 96 97 98]
[ 99 100 101]
[108 109 110]
[111 112 113]
[120 121 122]
[123 124 125]
[132 133 134]
[135 136 137]]
[[102 103 104]
[105 106 107]
[114 115 116]
[117 118 119]
[126 127 128]
[129 130 131]
[138 139 140]
[141 142 143]]
[[144 145 146]
[147 148 149]
[156 157 158]
[159 160 161]
[168 169 170]
[171 172 173]
[180 181 182]
[183 184 185]]
[[150 151 152]
[153 154 155]
[162 163 164]
[165 166 167]
[174 175 176]
[177 178 179]
[186 187 188]
[189 190 191]]]]
(1) https://www.tensorflow.org/api_docs/python/tf/nn/depth_to_space