Пример #1
0
 def softmax_pass():
     x = Any()
     pattern = Call(P.Softmax(), [x])
     imm = Imm(0)
     target_0 = Call("make_tuple", [pattern])
     target = Call(Constants.kTupleGetItem, [target_0, imm])
     return pattern, target
Пример #2
0
    def softmax_make_tuple_pass():
        x = Any()
        softmax = P.Softmax()
        pattern = Call(softmax, [x])

        target = Call("make_tuple", [pattern, new_para])
        return pattern, target
Пример #3
0
 def softmax_pass():
     x = Any()
     pattern = Call(P.Softmax(), [x])
     imm = Imm(0)
     target_0 = Call("make_tuple", [pattern])
     target = Call("tuple_getitem", [target_0, imm])
     return pattern, target
Пример #4
0
    def softmax_addn_pass():
        x = Any()
        pattern = Call(P.Softmax(), [x])

        weight_tensor = Tensor(np.zeros([42]), mindspore.float16)
        new_weight = NewTensor(weight_tensor)
        target = Call(P.AddN(), [x, new_weight])
        return pattern, target
Пример #5
0
 def softmax_relu_pass():
     x = Any()
     softmax_pattern = Prim(P.Softmax())
     pattern = Call(softmax_pattern, [x])
     sigmoid_pattern = Prim(P.Sigmoid())
     call_sigmoid = Call(sigmoid_pattern, [x])
     relu_pattern = Prim(P.ReLU())
     target = Call(relu_pattern, [call_sigmoid])
     return pattern, target
Пример #6
0
    def softmax_addn_pass():
        x = Any()
        pattern = Call(P.Softmax(), [x])

        default_tensor0 = Tensor(np.ones((4, 4)), mindspore.float32)
        default_tensor1 = Tensor(np.ones((4, 4)), mindspore.float32)
        new_para_0 = NewParameter("Merlin", default_tensor0)
        new_para_1 = NewParameter("Arthur", default_tensor1)
        target_0 = Call(P.MatMul(), [new_para_0, new_para_1])
        target = Call("make_tuple", [target_0])
        return pattern, target
Пример #7
0
    def softmax_neg_pass():
        x = Any()
        softmax_pattern = Prim(P.Softmax())
        call_softmax = Call(softmax_pattern, [x])
        relu_pattern = Prim(P.ReLU())
        call_relu = Call(relu_pattern, [x])

        pattern = OneOf([call_softmax, call_relu])
        neg_ops = Prim(P.Neg())
        target = Call(neg_ops, [pattern])
        return pattern, target
Пример #8
0
    def softmax_relu_pass():
        x = Any()
        softmax_pattern = Prim(P.Softmax())
        call_softmax = Call(softmax_pattern, [x])
        relu_pattern = Prim(P.ReLU())
        call_relu = Call(relu_pattern, [x])

        pattern = OneOf([call_softmax, call_relu])
        relu6_pattern = Prim(P.ReLU6())
        target = Call(relu6_pattern, [x])
        return pattern, target
Пример #9
0
 def softmax_relu_pass():
     x = Any()
     sigmoid_softmax_pattern = Prim([P.Sigmoid(), P.Softmax()])
     pattern = Call(sigmoid_softmax_pattern, [x])
     target = Call(P.ReLU(), [x])
     return pattern, target
Пример #10
0
 def softmax_relu_pass():
     x = Any()
     pattern = Call(P.Softmax(), [x])
     target = Call(P.ReLU(), [x])
     return pattern, target