Skip to content

Commit

Permalink
Added modules
Browse files Browse the repository at this point in the history
  • Loading branch information
JVGD committed Oct 23, 2021
1 parent 19f8cae commit 3f39c18
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions experiment1/modules.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 3f39c18

Please sign in to comment.