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

Method __sub__

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

Source from the content-addressed store, hash-verified

72 return result
73
74 def __sub__(self, other: Variable) -> Variable:
75 result = Variable(self.value - other.value)
76
77 with GradientTracker() as tracker:
78 # if tracker is enabled, computation graph will be updated
79 if tracker.enabled:
80 tracker.append(OpType.SUB, params=[self, other], output=result)
81 return result
82
83 def __mul__(self, other: Variable) -> Variable:
84 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