Skip to content

[Unet/tensorflow2] loss function with softmax output #468

Description

@pcasl

Related to UNet_Medical/TensorFlow2
TensorFlow2/Segmentation/UNet_Medical

Describe the bug
In the U-Net model, the last line, the output is with keras soft_max:
tf.keras.activations.softmax(out, axis=-1)

In the loss function, line 35, the crossentropy is calculated with tf.nn.softmax_cross_entropy_with_logits.

However, as mentioned by the tensorflow2 library, https://www.tensorflow.org/api_docs/python/tf/nn/softmax_cross_entropy_with_logits
WARNING: This op expects unscaled logits, since it performs a softmax on logits internally for efficiency. Do not call this op with the output of softmax, as it will produce incorrect results.

So, I think this is a bug. Please correct me if I am wrong. Thank you.

Expected behavior
If it is bug, it should be change to be corrected

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions