AI-DSW 上编辑嵌套式模型实现Resnet手势识别

0
0
0
1. 云栖社区>
2. 博客>
3. 正文

## AI-DSW 上编辑嵌套式模型实现Resnet手势识别

huangzhe118 2020-05-16 23:17:33 浏览320

## AI-DSW 上编辑嵌套式模型实现Resnet手势识别

AI-DSW（Data science workshop）是专门为算法开发者准备的云端深度学习开发环境，

• KerasCode：先写深度学习网络代码，然后将代码转成图
• KerasGraph：直接通过画布构建深度学习网络，并且将图转成代码

def Conv2d_BN(x, nb_filter, kernel_size, strides=(1, 1), padding='same'):

x = BatchNormalization(axis=3)(x)
x = Activation('relu')(x)
return x

def identity_Block(inpt, nb_filter, kernel_size, strides=(1, 1), with_conv_shortcut=False):
x = Conv2d_BN(inpt, nb_filter=nb_filter, kernel_size=kernel_size, strides=strides, padding='same')
x = Conv2d_BN(x, nb_filter=nb_filter, kernel_size=kernel_size, padding='same')
if with_conv_shortcut:#shortcut的含义是：将输入层x与最后的输出层y进行连接，如上图所示
shortcut = Conv2d_BN(inpt, nb_filter=nb_filter, strides=strides, kernel_size=kernel_size)
return x
else:
return x

def resnet_18(width,height,channel,classes):
inpt = Input(shape=(width, height, channel))

#conv1
x = Conv2d_BN(inpt, nb_filter=64, kernel_size=(7, 7), strides=(2, 2), padding='valid')
x = MaxPooling2D(pool_size=(3, 3), strides=(2, 2), padding='same')(x)

#conv2_x
x = identity_Block(x, nb_filter=64, kernel_size=(3, 3))
x = identity_Block(x, nb_filter=64, kernel_size=(3, 3))

#conv3_x
x = identity_Block(x, nb_filter=128, kernel_size=(3, 3), strides=(2, 2), with_conv_shortcut=True)
x = identity_Block(x, nb_filter=128, kernel_size=(3, 3))

#conv4_x
x = identity_Block(x, nb_filter=256, kernel_size=(3, 3), strides=(2, 2), with_conv_shortcut=True)
x = identity_Block(x, nb_filter=256, kernel_size=(3, 3))

#conv5_x
x = identity_Block(x, nb_filter=512, kernel_size=(3, 3), strides=(2, 2), with_conv_shortcut=True)
x = identity_Block(x, nb_filter=512, kernel_size=(3, 3))

x = GlobalAvgPool2D()(x)
x = Dense(classes, activation='softmax')(x)

model = Model(inputs=inpt, outputs=x)
return model

• 暂不支持各类预训练模型，比如keras_bert，resnet这些，不过在支持了预训练模型，甚至支持对预训练模型最后几层做编辑，将大大提升实用性
• KerasGraph图形化界面前端占用过多内存，有的时候会导致页面卡塞
• KerasGraph对于各层参数编辑和定义易用性还需要提升，目前并不比查阅文档方便多少

huangzhe118
+ 关注