ValueError: `logits` and `labels` must have the same shape, received ((None, 256, 256, 4) vs (None,))

def conv_block(input, num_filters):
x = Conv2D(num_filters, 3, padding=“same”)(input)
x = BatchNormalization()(x) #Not in the original network.
x = Activation(“relu”)(x)

x = Conv2D(num_filters, 3, padding="same")(x)
x = BatchNormalization()(x)  #Not in the original network
x = Activation("relu")(x)

return x

def encoder_block(input, num_filters):
x = conv_block(input, num_filters)
p = MaxPool2D((2, 2))(x)
return x, p

def decoder_block(input, skip_features, num_filters):
x = Conv2DTranspose(num_filters, (2, 2),strides=2,padding=“same”)(input)
x = Concatenate()([x, skip_features])
x = conv_block(x, num_filters)
return x

def build_unet(input_shape, n_classes):
inputs = Input(input_shape)

s1, p1 = encoder_block(inputs, 64)
s2, p2 = encoder_block(p1, 128)
s3, p3 = encoder_block(p2, 256)
s4, p4 = encoder_block(p3, 512)

b1 = conv_block(p4, 1024) #Bridge

d1 = decoder_block(b1, s4, 512)
d2 = decoder_block(d1, s3, 256)
d3 = decoder_block(d2, s2, 128)
d4 = decoder_block(d3, s1, 64)

if n_classes == 1:
  activation = 'sigmoid'
  activation = 'softmax'

outputs = Conv2D(n_classes, 1, padding="same", activation=activation)(d4)  

model = Model(inputs, outputs, name="U-Net")

return model

my_unet = build_unet(input_shape=(256,256,3), n_classes=4)


my_unet.compile(optimizer=tf.keras.optimizers.Adam(), loss=‘binary_crossentropy’, metrics=[‘accuracy’])

history =


can somebody help me with this code

It seems you are using Keras so I would recommend to post the question in the TensorFlow discussion board as you will find the experts there.
Based on the error message I would recommend to check the model output and compare it to the targets as it seems your loss function expects the same shapes for both.