Returns the list of input tensors necessary to compute `tensor`. Output will always be a list of tensors (potentially with 1 element). Arguments: tensor: The tensor to start from. layer: Origin layer of the tensor. Will be determined via tensor._keras_history if not pro
(tensor, layer=None, node_index=None)
| 30 | |
| 31 | @keras_export('keras.utils.get_source_inputs') |
| 32 | def get_source_inputs(tensor, layer=None, node_index=None): |
| 33 | """Returns the list of input tensors necessary to compute `tensor`. |
| 34 | |
| 35 | Output will always be a list of tensors |
| 36 | (potentially with 1 element). |
| 37 | |
| 38 | Arguments: |
| 39 | tensor: The tensor to start from. |
| 40 | layer: Origin layer of the tensor. Will be |
| 41 | determined via tensor._keras_history if not provided. |
| 42 | node_index: Origin node index of the tensor. |
| 43 | |
| 44 | Returns: |
| 45 | List of input tensors. |
| 46 | """ |
| 47 | if not hasattr(tensor, '_keras_history'): |
| 48 | return tensor |
| 49 | |
| 50 | if layer is None or node_index: |
| 51 | layer, node_index, _ = tensor._keras_history |
| 52 | if not layer._inbound_nodes: |
| 53 | return [tensor] |
| 54 | else: |
| 55 | node = layer._inbound_nodes[node_index] |
| 56 | if not node.inbound_layers: |
| 57 | # Reached an Input layer, stop recursion. |
| 58 | return nest.flatten(node.input_tensors) |
| 59 | else: |
| 60 | source_tensors = [] |
| 61 | for layer, node_index, _, tensor in node.iterate_inbound(): |
| 62 | previous_sources = get_source_inputs(tensor, layer, node_index) |
| 63 | # Avoid input redundancy. |
| 64 | for x in previous_sources: |
| 65 | if all(x is not t for t in source_tensors): |
| 66 | source_tensors.append(x) |
| 67 | return source_tensors |
| 68 | |
| 69 | |
| 70 | def count_params(weights): |
nothing calls this directly
no test coverage detected