{"record":{"id":"126aff2904c97bca","repo":"tensorflow/models","slug":"input-path-and-weights-must-both-be-a-config-to-us","errorCode":null,"errorMessage":"input_path and weights must both be a Config to use weighted sampling.","messagePattern":"input_path and weights must both be a Config to use weighted sampling\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/dataloaders/input_reader.py","lineNumber":63,"sourceCode":"\n\ndef create_combine_fn(\n    params: cfg.DataConfig\n) -> Union[None, Callable[[tf.data.Dataset], tf.data.Dataset]]:\n  \"\"\"Creates and returns a combine_fn for dataset mixing.\"\"\"\n  if (\n      hasattr(params, 'stop_on_empty_dataset')\n      and params.stop_on_empty_dataset is not None\n  ):\n    stop_on_empty_dataset = params.stop_on_empty_dataset\n  else:\n    stop_on_empty_dataset = True\n\n  if params.weights:\n    # Combine multiple datasets using weighted sampling.\n    if (not isinstance(params.input_path, cfg.base_config.Config) or\n        not isinstance(params.weights, cfg.base_config.Config)):\n      raise ValueError(\n          'input_path and weights must both be a Config to use weighted '\n          'sampling.')\n    input_paths = params.input_path.as_dict()\n    weights = params.weights.as_dict()\n    if len(input_paths) != len(weights):\n      raise ValueError(\n          'The number of input_path and weights must be the same, but got %d '\n          'input_paths and %d weights.' % (len(input_paths), len(weights)))\n\n    for k in input_paths.keys():\n      if k not in weights:\n        raise ValueError(\n            'input_path key \\'%s\\' does not have a corresponding weight.' % k)\n\n    return build_weighted_sampling_combine_fn(weights, stop_on_empty_dataset)\n  return None\n\n","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/dataloaders/input_reader.py#L45-L81","documentation":"Error \"input_path and weights must both be a Config to use weighted sampling.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/dataloaders/input_reader.py:63 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"}