{"record":{"id":"2e8cde10fe365802","repo":"tensorflow/models","slug":"the-iterator-output-is-neither-a-tuple-nor-a-dicti","errorCode":null,"errorMessage":"The iterator output is neither a tuple nor a dictionary. It is not implemented to support such outputs.","messagePattern":"The iterator output is neither a tuple nor a dictionary\\. It is not implemented to support such outputs\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/modeling/multitask/multitask.py","lineNumber":130,"sourceCode":"      multi_task_model: a MultiTaskBaseModel instance.\n      optimizer: a tf.optimizers.Optimizer.\n      task_metrics: a dictionary of task names and per-task metrics.\n      **kwargs: other arguments to pass through.\n\n    Returns:\n      A dictionary of losses, inculding per-task losses and their weighted sum.\n    \"\"\"\n    losses = {}\n    with tf.GradientTape() as tape:\n      total_loss = 0.0\n      for name, model in multi_task_model.sub_tasks.items():\n        inputs = task_inputs[name]\n        if isinstance(inputs, tuple) and len(inputs) == 2:\n          features, labels = inputs\n        elif isinstance(inputs, dict):\n          features, labels = inputs, inputs\n        else:\n          raise ValueError(\"The iterator output is neither a tuple nor a \"\n                           \"dictionary. It is not implemented to support \"\n                           \"such outputs.\")\n        outputs = model(features, training=True)\n        task_loss = self.tasks[name].build_losses(labels, outputs)\n        task_weight = self.task_weight(name)\n        total_loss += task_weight * task_loss\n        losses[name] = task_loss\n        self.tasks[name].process_metrics(task_metrics[name], labels, outputs,\n                                         **kwargs)\n\n      # Scales loss as the default gradients allreduce performs sum inside\n      # the optimizer.\n      scaled_loss = total_loss / tf.distribute.get_strategy(\n      ).num_replicas_in_sync\n    tvars = multi_task_model.trainable_variables\n    grads = tape.gradient(scaled_loss, tvars)\n    optimizer.apply_gradients(list(zip(grads, tvars)))\n    losses[\"total_loss\"] = total_loss","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/modeling/multitask/multitask.py#L112-L148","documentation":"Error \"The iterator output is neither a tuple nor a dictionary. It is not implemented to support such outputs.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/modeling/multitask/multitask.py:130 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}