Issue
On training my model which I have built for 3D Unet using keras I'm getting ValueError: Input 0 of layer conv3d_46 is incompatible with the layer: expected ndim=5, found ndim=6. Full shape received: [None, 2, 256, 256, 120, 4]. The size of shape of my data is (2, 256, 256, 120, 4).
Model:
data = Input(shape=inp_shape)
flt=32
conv1 = Conv3D(flt, (3, 3, 3), activation='relu', padding='same')(data)
conv1 = Conv3D(flt, (3, 3, 3), activation='relu', padding='same')(conv1)
pool1 = MaxPooling3D(pool_size=(2, 2, 2))(conv1)
conv2 = Conv3D(flt*2, (3, 3, 3), activation='relu', padding='same')(pool1)
conv2 = Conv3D(flt*2, (3, 3, 3), activation='relu', padding='same')(conv2)
pool2 = MaxPooling3D(pool_size=(2, 2, 2))(conv2)
conv3 = Conv3D(flt*4, (3, 3, 3), activation='relu', padding='same')(pool2)
conv3 = Conv3D(flt*4, (3, 3, 3), activation='relu', padding='same')(conv3)
pool3 = MaxPooling3D(pool_size=(2, 2, 2))(conv3)
conv4 = Conv3D(flt*8, (3, 3, 3), activation='relu', padding='same')(pool3)
conv4 = Conv3D(flt*8, (3, 3, 3), activation='relu', padding='same')(conv4)
pool4 = MaxPooling3D(pool_size=(2, 2, 2))(conv4)
conv5 = Conv3D(flt*16, (3, 3, 3), activation='relu', padding='same')(pool4)
conv5 = Conv3D(flt*8, (3, 3, 3), activation='relu', padding='same')(conv5)
up6 = concatenate([Conv3DTranspose(flt*8, (2, 2, 2), strides=(2, 2, 2), padding='same')(conv5), conv4], axis=-1)
conv6 = Conv3D(flt*8, (3, 3, 3), activation='relu', padding='same')(up6)
conv6 = Conv3D(flt*4, (3, 3, 3), activation='relu', padding='same')(conv6)
up7 = concatenate([Conv3DTranspose(flt*4, (2, 2, 2), strides=(2, 2, 2), padding='same')(conv6), conv3], axis=-1)
conv7 = Conv3D(flt*4, (3, 3, 3), activation='relu', padding='same')(up7)
conv7 = Conv3D(flt*2, (3, 3, 3), activation='relu', padding='same')(conv7)
up8 = concatenate([Conv3DTranspose(flt*2, (2, 2, 2), strides=(2, 2, 2), padding='same')(conv7), conv2], axis=4)
conv8 = Conv3D(flt*2, (3, 3, 3), activation='relu', padding='same')(up8)
conv8 = Conv3D(flt, (3, 3, 3), activation='relu', padding='same')(conv8)
up9 = concatenate([Conv3DTranspose(flt, (2, 2, 2), strides=(2, 2, 2), padding='same')(conv8), conv1], axis=4)
conv9 = Conv3D(flt, (3, 3, 3), activation='relu', padding='same')(up9)
conv9 = Conv3D(flt, (3, 3, 3), activation='relu', padding='same')(conv9)
conv10 = Conv3D(2, (1,1,1), activation='sigmoid')(conv9)
model = Model(inputs=[data], outputs=[conv10])
To train the model the code is as follows:-
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['binary_accuracy'])
Solution
The target labels have the last dimension as 2. The output of the model has the last dimension as 1. Thanks @Shubham Panchal
Answered By - user3551487
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.