{"record":{"id":"6a2733247d031f13","repo":"keras-team/keras","slug":"output-with-path-path-is-not-connected-to-inp","errorCode":null,"errorMessage":"Output with path `{path}` is not connected to `inputs`","messagePattern":"Output with path `(.+?)` is not connected to `inputs`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/ops/function.py","lineNumber":221,"sourceCode":"                    # Use call_fn if provided (e.g., for symbolic execution)\n                    op = operation_fn(node.operation)\n                    outputs = call_fn(op, *args, **kwargs)\n                else:\n                    # Use NNX operation mapping\n                    operation = self._get_operation_for_node(node)\n                    op = operation_fn(operation)\n                    outputs = op(*args, **kwargs)\n\n                # Update tensor_dict.\n                for x, y in zip(node.outputs, tree.flatten(outputs)):\n                    tensor_dict[id(x)] = y\n\n        output_tensors = []\n        for i, x in enumerate(self.outputs):\n            if id(x) not in tensor_dict:\n                path = tree.flatten_with_path(self._outputs_struct)[i][0]\n                path = \".\".join(str(p) for p in path)\n                raise ValueError(\n                    f\"Output with path `{path}` is not connected to `inputs`\"\n                )\n            output_tensors.append(tensor_dict[id(x)])\n\n        return tree.pack_sequence_as(self._outputs_struct, output_tensors)\n\n    def _assert_input_compatibility(self, inputs):\n        try:\n            tree.assert_same_structure(inputs, self._inputs_struct)\n        except ValueError:\n            raise ValueError(\n                \"Function was called with an invalid input structure. \"\n                f\"Expected input structure: {self._inputs_struct}\\n\"\n                f\"Received input structure: {inputs}\"\n            )\n        for x, x_ref in zip(tree.flatten(inputs), self._inputs):\n            if len(x.shape) != len(x_ref.shape):\n                raise ValueError(","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/ops/function.py#L203-L239","documentation":"When evaluating a Function graph, every declared output must be reachable by traversing from the declared inputs. An output that came from different tensors (constants, another graph) fails this reachability check.","triggerScenarios":"keras.ops.Function([x], [y]) where y was created independently of x (e.g. y = other_tensor + 1)","commonSituations":"Functional model construction where a return value comes from a layer applied outside the input graph, or accidental tensor reuse across models","solutions":["Compute the output from the input tensors via ops/layers","Add the missing source tensor to inputs","Remove the stray output from the outputs structure"],"exampleFix":"# before\ny = some_other_input + 1\nfn = keras.ops.Function([x], y)\n\n# after\ny = x + 1\nfn = keras.ops.Function([x], y)","handlingStrategy":"validation","validationCode":"out_flat = tree.flatten(outputs)\nin_ids = {id(t) for t in tree.flatten(inputs)}\nassert out_flat, 'outputs empty'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Compute outputs from the inputs, not from captured constants","Trace the op graph with keras.ops.Function to verify connectivity before saving"],"tags":["keras","ops","function","graph"],"backgroundTag":"disconnected-graph","analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}