MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __add__

Method __add__

machine_learning/automatic_differentiation.py:65–72  ·  view source on GitHub ↗
(self, other: Variable)

Source from the content-addressed store, hash-verified

63 return self.value
64
65 def __add__(self, other: Variable) -> Variable:
66 result = Variable(self.value + other.value)
67
68 with GradientTracker() as tracker:
69 # if tracker is enabled, computation graph will be updated
70 if tracker.enabled:
71 tracker.append(OpType.ADD, params=[self, other], output=result)
72 return result
73
74 def __sub__(self, other: Variable) -> Variable:
75 result = Variable(self.value - other.value)

Callers

nothing calls this directly

Calls 3

VariableClass · 0.85
GradientTrackerClass · 0.85
appendMethod · 0.45

Tested by

no test coverage detected