Beispiel #1
0
    def test_der(self):
        obj1 = make_autoTensor([[-3,3],[4,5]])
        obj2 = make_autoTensor([[-3,3],[4,5]])
        obj1.requires_grad = True
        obj = Add(obj1,obj2)
        obj.backprop(make_autoTensor([[1,1],[1,1]]))

        assert torch.sum(obj1.grad.value - make_autoTensor([[1,1],[1,1]]).value) == 0
Beispiel #2
0
    def test_init(self):
        obj1 = make_autoTensor([[-3,3],[4,5]])
        obj2 = make_autoTensor([[-3,3],[4,5]])
        obj1.requires_grad = True
        obj = Add(obj1,obj2)

        assert obj.channels[0].autoVariable == obj1
Beispiel #3
0
 def __radd__(self, other):
     return Add(self, make_autoTensor(other))
Beispiel #4
0
 def Add(self, other):
     return Add(self, make_autoTensor(other))