栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Tensorflow:对于小批量中的每个样本,使用不同的滤波器进行卷积

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Tensorflow:对于小批量中的每个样本,使用不同的滤波器进行卷积

我认为建议的技巧实际上是不正确的。

tf.conv3d()
图层发生的事情是将输入卷积到深度(=实际批处理)维度上,然后沿着结果要素图求和。随着
padding='SAME'
所产生的产出数量则恰好是同批大小,这样一个被愚弄!

编辑:我认为对不同的迷你批处理元素使用不同的滤镜进行卷积的一种可能方法涉及“破解”深度卷积。假设批量大小

MB
已知:

inp = tf.placeholder(tf.float32, [MB, H, W, channels_img])# F has shape (MB, fh, fw, channels, out_channels)# REM: with the notation in the question, we need: channels_img==channelsF = tf.transpose(F, [1, 2, 0, 3, 4])F = tf.reshape(F, [fh, fw, channels*MB, out_channels)inp_r = tf.transpose(inp, [1, 2, 0, 3]) # shape (H, W, MB, channels_img)inp_r = tf.reshape(inp, [1, H, W, MB*channels_img])out = tf.nn.depthwise_conv2d(          inp_r,          filter=F,          strides=[1, 1, 1, 1],          padding='VALID') # here no requirement about padding being 'VALID', use whatever you want. # Now out shape is (1, H, W, MB*channels*out_channels)out = tf.reshape(out, [H, W, MB, channels, out_channels) # careful about the order of depthwise conv out_channels!out = tf.transpose(out, [2, 0, 1, 3, 4])out = tf.reduce_sum(out, axis=3)# out shape is now (MB, H, W, out_channels)

如果

MB
未知,应该可以使用
tf.shape()
(我认为)动态确定



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/646485.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号