Adds Operation object to the related Variable objects for creating computational graph for calculating gradients. Args: op_type: Operation type params: Input parameters to the operation output: Output variable of the operation
(
self,
op_type: OpType,
params: list[Variable],
output: Variable,
other_params: dict | None = None,
)
| 219 | self.enabled = False |
| 220 | |
| 221 | def append( |
| 222 | self, |
| 223 | op_type: OpType, |
| 224 | params: list[Variable], |
| 225 | output: Variable, |
| 226 | other_params: dict | None = None, |
| 227 | ) -> None: |
| 228 | """ |
| 229 | Adds Operation object to the related Variable objects for |
| 230 | creating computational graph for calculating gradients. |
| 231 | |
| 232 | Args: |
| 233 | op_type: Operation type |
| 234 | params: Input parameters to the operation |
| 235 | output: Output variable of the operation |
| 236 | """ |
| 237 | operation = Operation(op_type, other_params=other_params) |
| 238 | param_nodes = [] |
| 239 | for param in params: |
| 240 | param.add_param_to(operation) |
| 241 | param_nodes.append(param) |
| 242 | output.add_result_of(operation) |
| 243 | |
| 244 | operation.add_params(param_nodes) |
| 245 | operation.add_output(output) |
| 246 | |
| 247 | def gradient(self, target: Variable, source: Variable) -> np.ndarray | None: |
| 248 | """ |
no test coverage detected