Class represents operation between single or two Variable objects. Operation objects contains type of operation, pointers to input Variable objects and pointer to resulting Variable from the operation.
| 129 | |
| 130 | |
| 131 | class Operation: |
| 132 | """ |
| 133 | Class represents operation between single or two Variable objects. |
| 134 | Operation objects contains type of operation, pointers to input Variable |
| 135 | objects and pointer to resulting Variable from the operation. |
| 136 | """ |
| 137 | |
| 138 | def __init__( |
| 139 | self, |
| 140 | op_type: OpType, |
| 141 | other_params: dict | None = None, |
| 142 | ) -> None: |
| 143 | self.op_type = op_type |
| 144 | self.other_params = {} if other_params is None else other_params |
| 145 | |
| 146 | def add_params(self, params: list[Variable]) -> None: |
| 147 | self.params = params |
| 148 | |
| 149 | def add_output(self, output: Variable) -> None: |
| 150 | self.output = output |
| 151 | |
| 152 | def __eq__(self, value) -> bool: |
| 153 | return self.op_type == value if isinstance(value, OpType) else False |
| 154 | |
| 155 | |
| 156 | class GradientTracker: |