{"record":{"id":"f716cbe579e902ab","repo":"tensorflow/models","slug":"num-classes-should-be-given-when-requesting-one-ho","errorCode":null,"errorMessage":"num_classes should be given when requesting one hot label.","messagePattern":"num_classes should be given when requesting one hot label\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/videoglue/datasets/common/utils.py","lineNumber":588,"sourceCode":"      for different label features.\n    output_label_name_feature_name: Name of the label name feature in the\n      output features dictionary. Exposing this as an argument allows using this\n      function for different label features.\n    num_frames: The number of frames. If the num_frames > 1, the labels will be\n      duplicated.\n    num_instances_per_frame: The number of label instances per frames.\n    zero_based_index: Whether the raw index are zero based. If not, converted to\n      the zero based index as the output.\n    one_hot_label: Return labels as one hot tensors. If is_multi_label is True,\n      one hot tensor might have multiple ones.\n    num_classes: Total number of classes in the dataset. It has to be procided\n      if one_hot_label is True.\n    add_label_name: Also return the name of the label. Not yet supported for\n      multi label.\n  \"\"\"\n  # Validate parameters.\n  if one_hot_label and not num_classes:\n    raise ValueError(\n        'num_classes should be given when requesting one hot label.')\n\n  # Parse label.\n  parser_builder.parse_feature(\n      feature_name=input_label_index_feature_name,\n      feature_type=tf.io.VarLenFeature(dtype=tf.int64),\n      output_name=output_label_index_feature_name,\n      is_context=True)\n\n  # Densify labels tensor in order to support multi label case.\n  sampler_builder.add_fn(\n      fn=lambda x: tf.sparse.to_dense(x, default_value=-1),\n      feature_name=output_label_index_feature_name,\n      fn_name='{}_sparse_to_dense'.format(output_label_index_feature_name))\n\n  # Crop or pad labels to max_num_instance.\n  crop_or_pad_features_fn = functools.partial(\n      processors.crop_or_pad_features,","sourceCodeStart":570,"sourceCodeEnd":606,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/videoglue/datasets/common/utils.py#L570-L606","documentation":"Error \"num_classes should be given when requesting one hot label.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/videoglue/datasets/common/utils.py:588 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"}