Ejemplo n.º 1
0
    def __call__(self, logits, ys):
        forward = solution.SigmoidCrossEntropyForward()
        backward = solution.SigmoidCrossEntropyBackward()

        ctx = dict()
        average_loss = forward(logits, ys, ctx=ctx)
        dlogits = backward(ctx, 1.0)

        for d in range(self.batch_size):
            real_dlogits = np.zeros_like(logits)
            real_dlogits[d] = self.delta

            moved_logits = logits + real_dlogits
            moved_average_loss = forward(moved_logits, ys)
            assert np.all(
                np.absolute((moved_average_loss - average_loss) / self.delta -
                            dlogits[d]) < 1e-5
            ), 'Value mismatch in dimension {}.'.format(d)
Ejemplo n.º 2
0
 def __init__(self):
     self._forward = solution.SigmoidCrossEntropyForward()
     self._backward = solution.SigmoidCrossEntropyBackward()
Ejemplo n.º 3
0
 def __call__(self):
     forward = solution.SigmoidCrossEntropyForward()
     self.positive_monotonically_decreasing(forward)
     self.negative_monotonically_increasing(forward)