Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Stuck at a condition with gluon.loss.Loss #20042

Answered by szha
BebDong asked this question in Q&A
Discussion options

You must be logged in to vote

Assuming the two operations return the same shape, you can try

def __init__:
    self._threshold = self.params.get_constant('threshold', nd.array([threshold, ], dtype='float32'))

def hybrid_forward(self, F, logit, label, threshold):
    ...
    return F.where(
        F.greater(loss[self.idx], threshold),
        operation1,
        operation2)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@BebDong
Comment options

@BebDong
Comment options

Answer selected by szha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants