YW *_*won 6 python deep-learning tensorflow
我正在尝试实现层之间的部分连接。比方说,我只想使用一些特征图,例如,第一个和第三个。
代码:
# let say, L1 is layer1 output of shape [batch_size x image_size x image_size x depth1]
partL1 = L1[:, :, :, [0,2]]
# W2 is a tf variable of shape [5, 5, 2, depth2]
conv2 = tf.nn.conv2d(partL1, W2)
Run Code Online (Sandbox Code Playgroud)
是的,不,是的。:-) (a) 是的,您可以按照您的建议使用收集来选择层的子集以传播到下一层。
(b) 不,不幸的是,您不能使用索引运算符。您需要显式调用tf.gather().
(c) 是的,TensorFlow 将存储用于收集的索引副本并将其保存以用于反向传播。如果您好奇如何实现,您可以查看Gather's Gradient 的实现- 它查看操作的输入并使用这些输入传播回来。
| 归档时间: |
|
| 查看次数: |
1156 次 |
| 最近记录: |