Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model Shape Don't Match #5

Open
WuJammy opened this issue Jun 20, 2024 · 0 comments
Open

Model Shape Don't Match #5

WuJammy opened this issue Jun 20, 2024 · 0 comments

Comments

@WuJammy
Copy link

WuJammy commented Jun 20, 2024

' def create_model(input_shape=(320, 430, 3)):
visible = Input(shape=input_shape)
x = BatchNormalization()(visible)

## Bottom
# bm = BatchNormalization()(x)
bm = x
bm = Conv2D(16, (4, 1), padding='valid', strides=(4, 1), activation='selu')(bm) # 80
bm = Conv2D(16, (4, 1), padding='valid', strides=(4, 1), activation='selu')(bm) # 20
bm = Conv2D(16, (4, 1), padding='valid', strides=(4, 1), activation='selu')(bm) # 5
bm = Conv2D(1,  (5, 1), padding='valid', strides=(5, 1), activation='selu')(bm) # 1

# 保持高分辨率,关注细节
shape=input_shape
x_r, x_t, x_f = FTA_Module(x, (shape[0], shape[1], 32), 3, 3)
x = SF_Module([x_r, x_t, x_f], 32, 4, 4)
x = MaxPooling2D((2, 2))(x)

x_r, x_t, x_f = FTA_Module(x, (shape[0]//2, shape[1]//2, 64), 3, 3)
x = SF_Module([x_r, x_t, x_f], 64, 4, 4)
x = MaxPooling2D((2, 2))(x)

x_r, x_t, x_f = FTA_Module(x, (shape[0]//4, shape[1]//4, 128), 3, 3)
x = SF_Module([x_r, x_t, x_f], 128, 4, 4)

x_r, x_t, x_f = FTA_Module(x, (shape[0]//4, shape[1]//4, 128), 3, 3)
x = SF_Module([x_r, x_t, x_f], 128, 4, 4)

x = UpSampling2D((2, 2))(x)
x_r, x_t, x_f = FTA_Module(x, (shape[0]//2, shape[1]//2, 64), 3, 3)
x = SF_Module([x_r, x_t, x_f], 64, 4, 4)

x = UpSampling2D((2, 2))(x)
x_r, x_t, x_f = FTA_Module(x, (shape[0], shape[1], 32), 3, 3)
x = SF_Module([x_r, x_t, x_f], 32, 4, 4)

x_r, x_t, x_f = FTA_Module(x, (shape[0], shape[1], 1), 3, 3)
x = SF_Module([x_r, x_t, x_f], 1, 4, 4)
x = Concatenate(axis=1)([bm, x])

# Softmax
x = Lambda(K.squeeze, arguments={'axis': -1})(x) # (321, 430)
x = Softmax(axis=-2)(x)

return Model(inputs=visible, outputs=x)`

I run this code in ftanet.py(load your ftanet.h5). Input shape = (320, 430, 3)

Get this error '' ValueError: total size of new array must be unchanged, input_shape = [214, 64], output_shape = [1, 215, 64] ''

I think question is about Upsampling:

x_r, x_t, x_f = FTA_Module(x, (shape[0]//4, shape[1]//4, 128), 3, 3)
x = SF_Module([x_r, x_t, x_f], 128, 4, 4)      --------------------------> shape : (None, 80, 107, 128)

x = UpSampling2D((2, 2))(x)-----------------------------------------> shape: (None, 160, 214, 128)
x_r, x_t, x_f = FTA_Module(x, (shape[0]//2, shape[1]//2, 64), 3, 3)----> input shape : (None, 160, 215, 128)

How do you train your model? Initial Input shape is correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant