在keras中实现跳过连接 [英] Implementing skip connections in keras

查看:217
本文介绍了在keras中实现跳过连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在喀拉拉邦实施ApesNet.它具有一个具有跳过连接的ApesBlock.如何在keras中将其添加到顺序模型中? ApesBlock具有两个并行层,最后通过元素逐个添加来合并.

I am implementing ApesNet in keras. It has an ApesBlock that has skip connections. How do I add this to a sequential model in keras? The ApesBlock has two parallel layers that merge at the end by element-wise addition.

推荐答案

简单的答案是不要为此使用顺序模型,而应使用功能性API,然后实现跳过连接(也称为剩余连接)非常容易,如功能性API指南中的示例所示:

The easy answer is don't use a sequential model for this, use the functional API instead, implementing skip connections (also called residual connections) are then very easy, as shown in this example from the functional API guide:

from keras.layers import merge, Convolution2D, Input

# input tensor for a 3-channel 256x256 image
x = Input(shape=(3, 256, 256))
# 3x3 conv with 3 output channels (same as input channels)
y = Convolution2D(3, 3, 3, border_mode='same')(x)
# this returns x + y.
z = merge([x, y], mode='sum')

这篇关于在keras中实现跳过连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆