diff --git a/experiment1/modules.py b/experiment1/modules.py new file mode 100644 index 0000000..8ff38ec --- /dev/null +++ b/experiment1/modules.py @@ -0,0 +1,30 @@ +import torch as T + + +class Adder(object): + def __init__(self) -> None: + """Init adder module""" + super().__init__() + + def __call__(self, X: T.Tensor) -> T.Tensor: + """Calling the adding operation without gradient""" + with T.no_grad(): + return X[0] + X[1] + + +class Substracter(object): + def __init__(self) -> None: + """Init substracter module""" + super().__init__() + + def __call__(self, X: T.Tensor) -> T.Tensor: + """Calling the adding operation without gradient""" + with T.no_grad(): + return X[0] - X[1] + + +if __name__ == "__main__": + adder = Adder() + x = T.rand(2) + y = adder(x) + print(x,y) \ No newline at end of file