Example #1
0
 def __init__(self, record=None):
     super(BCELoss, self).__init__(record)
     self.sm_scalar = P.ScalarSummary()
     self.cast = P.Cast()
     self.record = record
     self.weight = None
     self.bce = P.BinaryCrossEntropy()
Example #2
0
 def __init__(self, weight=None, reduction='none'):
     super(BCELoss, self).__init__()
     self.binary_cross_entropy = P.BinaryCrossEntropy(reduction=reduction)
     self.weight_one = weight is None
     if not self.weight_one:
         self.weight = weight
     else:
         self.ones = P.OnesLike()
Example #3
0
     'desc_inputs': [[10, 32, 32, 32], [1, 32, 3, 3]],
     'desc_bprop': [[10, 32, 16, 16]]}),
 ('DepthwiseConv2dNative_2', {
     'block': P.DepthwiseConv2dNative(1, (3, 3), pad_mode="same", pad=0, stride=1),
     'desc_inputs': [[2592, 2048, 4, 4], [1, 2048, 3, 3]],
     'desc_bprop': [[2592, 2048, 4, 4]]}),
 ('SigmoidCrossEntropyWithLogits', {
     'block': P.SigmoidCrossEntropyWithLogits(),
     'desc_inputs': [[128, 10], [128, 10]],
     'desc_bprop': [[128, 10]]}),
 ('Pad', {
     'block': P.Pad(((1, 2), (2, 3))),
     'desc_inputs': [[7, 7]],
     'desc_bprop': [[10, 12]]}),
 ('BinaryCrossEntropy', {
     'block': P.BinaryCrossEntropy(),
     'desc_inputs': [[1, 2, 3], [1, 2, 3], [1, 2, 3]],
     'desc_bprop': []}),
 ('SparseApplyAdagrad', {
     'block': P.SparseApplyAdagrad(0.5),
     'desc_inputs': [[3, 3], [3, 3], [3, 3], Tensor(np.ones((3,), np.int32))],
     'desc_bprop': [3, 3],
     'skip': ['backward']}),
 ('Flatten_1', {
     'block': NetForFlatten(),
     'desc_inputs': [Tensor(np.ones([2, 3, 4]).astype(np.int32)), Tensor(np.ones([2, 12]).astype(np.int32))],
     'desc_bprop': [Tensor(np.ones([2, 12]).astype(np.int32))],
     'skip': ['backward']}),
 ('Flatten_2', {
     'block': NetForFlatten(),
     'desc_inputs': [Tensor(np.ones([8]).astype(np.int32)), Tensor(np.ones([8, 3]).astype(np.int32))],
 def __init__(self, reduction="none"):
     super(Net, self).__init__()
     self.BinaryCrossEntropy = P.BinaryCrossEntropy("none")