膨胀卷积的缺点_膨胀卷积反褶积(tensorflow)的一个例子

我以前没用过膨胀,但我用的是基于卷积的自动编码器。下面是一个采用输入大小28x28x1(如mnist图像)的体系结构示例。使用步幅为2时,尺寸将缩小到14x14x1,然后降至7x7x1。然后将其展平,然后减小到32,即编码大小。之后,一组跨距为2的转置卷积层将使大小恢复到28x28x1。在

下面是代码示例:def autoencoder_network(x):

encoder_14 = tf.layers.conv2d(x, filters=1, kernel_size=3, strides=2, padding='same', activation=tf.nn.relu)

encoder_7 = tf.layers.conv2d(encoder_14, filters=1,kernel_size=3, strides=2, padding='same', activation=tf.nn.relu)

flatten_dim = np.prod(encoder_7.get_shape().as_list()[1:])

flat = tf.reshape(encoder_7, [-1, flatten_dim])

code = tf.layers.dense(flat, 32, activation=tf.nn.relu)

hidden_decoder = tf.layers.dense(code, flatten_dim, activation=tf.nn.relu)

decoder_7 = tf.reshape(hidden_decoder, [-1, 7, 7, 1])

decoder_14 = tf.layers.conv2d_transpose(decoder_7, 1, 3, strides=2, padding='same', activation=tf.nn.relu)

output = tf.layers.conv2d_transpose(decoder_14, 1, 3, strides=2, padding='same', activation=tf.nn.relu)

return code, output

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值