MCPcopy
hub / github.com/TheAlgorithms/Python / append

Method append

machine_learning/automatic_differentiation.py:221–245  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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 """

Callers 15

similarity_searchFunction · 0.45
collect_datasetFunction · 0.45
pruneFunction · 0.45
aprioriFunction · 0.45
ascend_treeFunction · 0.45
mine_treeFunction · 0.45
fitMethod · 0.45
get_neighboursMethod · 0.45
astarFunction · 0.45
revise_centroidsFunction · 0.45
kmeansFunction · 0.45
predictMethod · 0.45

Calls 5

add_paramsMethod · 0.95
add_outputMethod · 0.95
OperationClass · 0.85
add_param_toMethod · 0.80
add_result_ofMethod · 0.80

Tested by

no test coverage detected