CNN模型的配置,用于识别顺序数据-CNN顶部的体系结构-并行层 [英] Configuration of CNN model for recognition of sequential data - Architecture of the top of the CNN - Parallel Layers

查看:128
本文介绍了CNN模型的配置,用于识别顺序数据-CNN顶部的体系结构-并行层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试配置一个网络,以对车牌之类的顺序数据进行字符识别. 现在,我想使用深度自动车牌识别系统中表3中指出的体系结构(链接:

I am trying to configure a network for character recognition of sequential data like license plates. Now I would like to use the architecture which is noted in Table 3 in Deep Automatic Licence Plate Recognition system (link: http://www.ee.iisc.ac.in/people/faculty/soma.biswas/Papers/jain_icgvip2016_alpr.pdf).

作者介绍的体系结构是这样的:

The architecture the authors presented is this one:

第一层很常见,但是我绊脚石的地方是体系结构的顶层(红色框部分).他们提到了11个并行层,我真的不确定如何在Python中获得此层.我编码了这种体系结构,但是它似乎不适合我.

The first layers are very common, but where I was stumbling was the top (the part in the red frame) of the architecture. They mention 11 parallel layers and I am really unsure how to get this in Python. I coded this architecture but it does not seem to be right to me.

model = Sequential()
model.add(Conv2D(64, kernel_size=(5, 5), input_shape = (32, 96, 3), activation = "relu"))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Conv2D(128, kernel_size=(3, 3), activation = "relu"))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Conv2D(256, kernel_size=(3, 3), activation = "relu"))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(1024, activation = "relu"))
model.add(Dense(11*37, activation="Softmax"))
model.add(keras.layers.Reshape((11, 37)))

有人可以帮忙吗?我该如何编码顶部才能获得与作者相同的体系结构?

Could someone help? How do I have to code the top to get an equal architecture like the authors?

推荐答案

下面的代码可以构建图像中描述的体系结构.

The code below can build the architecture described in the image.

import tensorflow as tf
from tensorflow.keras.models import Sequential, Model
from tensorflow.keras.layers import Conv2D, Flatten, MaxPooling2D, Dense, Input, Reshape, Concatenate, Dropout

def create_model(input_shape = (32, 96, 1)):
    input_img = Input(shape=input_shape)
    '''
    Add the ST Layer here.
    '''
    model = Conv2D(64, kernel_size=(5, 5), input_shape = input_shape, activation = "relu")(input_img)
    model = MaxPooling2D(pool_size=(2, 2))(model)
    model = Dropout(0.25)(model)

    model = Conv2D(128, kernel_size=(3, 3), input_shape = input_shape, activation = "relu")(model)
    model = MaxPooling2D(pool_size=(2, 2))(model)
    model = Dropout(0.25)(model)

    model = Conv2D(256, kernel_size=(3, 3), input_shape = input_shape, activation = "relu")(model)
    model = MaxPooling2D(pool_size=(2, 2))(model)
    model = Dropout(0.25)(model)

    model = Flatten()(model)
    backbone = Dense(1024, activation="relu")(model)

    branches = []
    for i in range(11):
        branches.append(backbone)
        branches[i] = Dense(37, activation = "softmax", name="branch_"+str(i))(branches[i])
    
    output = Concatenate(axis=1)(branches)
    output = Reshape((11, 37))(output)
    model = Model(input_img, output)

    return model

这篇关于CNN模型的配置,用于识别顺序数据-CNN顶部的体系结构-并行层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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