MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / Operation

Class Operation

machine_learning/automatic_differentiation.py:131–153  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

129
130
131class 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
156class GradientTracker:

Callers 2

__init__Method · 0.85
appendMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected