预测keras

时间:2017-08-09 01:13:35

标签: python tensorflow deep-learning keras theano

我正在开发一个基于分类的模型来预测图像中每个像素的12个概率,我已经建立了这个架构,但我不确定我是不是对不对,我是深度学习的新手。

编辑1:我被建议使用完全卷积方法,这意味着从不使用完全连接的层,我确实尝试过,这给了我更好的饱和预测通道,但它们从来没有最好的,这是我的架构,任何帮助??

编辑1架构:

def Build_Classification_Model():
    Kernel_Size_Val=4
    import keras
    from keras.models import Model
    from keras.layers import Flatten, Dense, Input, Reshape,concatenate,BatchNormalization,Dropout,Activation,Conv2D,MaxPool2D

    Input_Img=Input(shape=(Img_Size,Img_Size,1),name='Main_Input')
    #The First Conv Layer + BatchNormalization
    X=Conv2D(filters=4,kernel_size=Kernel_Size_Val,activation='relu',name='First_Conv_0',padding='same')(Input_Img)
    X=Conv2D(filters=4,kernel_size=Kernel_Size_Val,activation='relu',name='First_Conv_1',padding='same')(X)

    X=Conv2D(filters=8,kernel_size=Kernel_Size_Val,activation='relu',name='Second_Con_0',padding='same')(X)
    X=Conv2D(filters=8,kernel_size=Kernel_Size_Val,activation='relu',name='Second_Conv_1',padding='same')(X)

    X=Conv2D(filters=16,kernel_size=Kernel_Size_Val,activation='relu',name='Third_Conv_0',padding='same')(X)
    X=Conv2D(filters=16,kernel_size=Kernel_Size_Val,activation='relu',name='Third_Conv_1',padding='same')(X)

    X=Conv2D(filters=32,kernel_size=Kernel_Size_Val,activation='relu',name='Fourth_Conv_0',padding='same')(X)
    X=Conv2D(filters=32,kernel_size=Kernel_Size_Val,activation='relu',name='Fourth_Conv_1',padding='same')(X)

    X=Conv2D(filters=64,kernel_size=Kernel_Size_Val,activation='relu',name='Fifth_Conv_0',padding='same')(X)
    X=Conv2D(filters=64,kernel_size=Kernel_Size_Val,activation='relu',name='Fifth_Conv_1',padding='same')(X)


    U=Conv2D(filters=Num_Bins+1,kernel_size=Kernel_Size_Val,activation='softmax',padding='same')(X)
    V=Conv2D(filters=Num_Bins+1,kernel_size=Kernel_Size_Val,activation='softmax',padding='same')(X)

    X=concatenate([Input_Img,U,V])

    MyModel=Model(Input_Img,X)
    MyModel.compile(optimizer='adam',loss=keras.losses.categorical_crossentropy,metrics=['accuracy'])
    print(MyModel.summary())
    return MyModel

以下是我的基线架构的功能

def Build_Classificion_U_Model():
        import keras
        from keras.models import Model
        from keras.layers import Flatten, Dense, Input, Reshape,concatenate,BatchNormalization,Permute,Dropout
        from keras.layers import Conv2D
        from keras import regularizers 

        Input_Img=Input(shape=(Img_Size,Img_Size,1),name='Main_Input')     

        #The First Conv Layer + BatchNormalization
        X=Conv2D(filters=8,kernel_size=5,activation='relu',name='Conv1')(Input_Img)
        #The Second Conv Layer + BatchNormalization
        X=Conv2D(filters=16,kernel_size=5,activation='relu',name='Conv2')(X)
         #The Third Conv Layer + BatchNormalization
        X=Conv2D(filters=32,kernel_size=5,activation='relu',name='Convfsf3d')(X)

        X=Flatten()(X)

        X=Dense(units=256,activation='relu')(X)
        X=Dense(units=49152,activation='relu')(X)
        X=Reshape(target_shape=(Img_Size,Img_Size,12))(X)
        X=Conv2D(filters=12,kernel_size=1,activation='softmax')(X)
        X=concatenate(inputs=[Input_Img,X])

        MyModel=Model(Input_Img,X)
        MyModel.compile(optimizer='adam',loss=keras.losses.categorical_crossentropy,metrics=['accuracy'])
        print(MyModel.summary())
        return MyModel

我将解释我的架构,输入是关于64 * 64 * 1灰度图像,然后是许多卷积层然后它被展平然后在那里它跟着许多FC层,但最后一个是49152被重新整形回到(64 * 64 * 12)12这里表示概率,然后与输入层连接,与输出进行比较但它给我带来如此糟糕的结果,为什么?

0 个答案:

没有答案