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

Multi-Class usage #2

Open
Rekesse opened this issue Sep 3, 2022 · 0 comments
Open

Multi-Class usage #2

Rekesse opened this issue Sep 3, 2022 · 0 comments

Comments

@Rekesse
Copy link

Rekesse commented Sep 3, 2022

Hi, im new to deep learning and python, i have a question: in a multi-class semantic segmentation with 4 classes ( im using keras ) my model has a softmax activation and the input for the model.fit has shape : mask_train[batch, h, w, 4 ].
I can't understand if i have to uncomment these lines or not

def DiceLoss(y_true, y_pred, smooth=1e-6):

# if you are using this loss for multi-class segmentation then uncomment 
# following lines
# if y_pred.shape[-1] <= 1:
#     # activate logits
#     y_pred = tf.keras.activations.sigmoid(y_pred)
# elif y_pred.shape[-1] >= 2:
#     # activate logits
#     y_pred = tf.keras.activations.softmax(y_pred, axis=-1)
#     # convert the tensor to one-hot for multi-class segmentation
#     y_true = K.squeeze(y_true, 3)
#     y_true = tf.cast(y_true, "int32")
#     y_true = tf.one_hot(y_true, num_class, axis=-1)
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