使用Tensorlow 2.0实现CNN模型

2024-09-30 05:22:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我在我的项目中面临着很多错误,因为我是这个领域的新手。请帮我解决这些问题。 提前谢谢

请下载下面的文件并在jupyter中运行https://1drv.ms/u/s!AhSiPNeVlPcLhkXPp_9eMWc9b_mC?e=4foE3S

谨致问候, 马扎尔布哈里


Tags: 文件项目https错误jupytermc领域ms
1条回答
网友
1楼 · 发布于 2024-09-30 05:22:58

您应该将inception_module填充改为padding="same"。这将确保输出张量的高度和宽度与输入张量(32x32)相同

   def inception_module(x,chanDim):
    # x is the input  and chanDim is the dimension at which the convolution is applied
    # channel dimension
    conv_1x1_64 = conv_module(x, 64, 1, 1, (1, 1), chanDim,padding='same') # Convol x with 64 filters of 1X1
    conv_1x1_96 = conv_module(x, 96, 1, 1, (1, 1), chanDim,padding="same") # convol x with 96 filters of 1X1
    conv_1x1_16 = conv_module(x, 16, 1, 1, (1, 1), chanDim,padding="same") # convol x with 16 filters of 1X1 
    conv_3x3 = conv_module(conv_1x1_96, 128, 3, 3, (1, 1), chanDim,padding="same") # convol conv_1x1_96 with 128 3X3 filters
    conv_5x5 = conv_module(conv_1x1_16, 32, 5, 5, (1, 1), chanDim,padding="same") # Convol the conv_1x1_16 with 32 5X5 filters
    maxpool = MaxPooling2D((3, 3), strides=(1, 1), padding='same')(x) # Perform MaxPooling of 3X3, with strides=1
    # padding='same'. Hint:  use MaxPooling2D function 
    conv_1x1_32 = conv_module(maxpool, 32, 1, 1, (1, 1), chanDim,padding="same") # convol maxpool with 32 filters of 1X1
    x = concatenate([conv_1x1_64, conv_3x3, conv_5x5,conv_1x1_32], axis=chanDim)

    return x

相关问题 更多 >

    热门问题