{"record":{"id":"574b12f9f1ca79ca","repo":"tensorflow/models","slug":"factor-must-be-positive","errorCode":null,"errorMessage":"`factor` must be positive.","messagePattern":"`factor` must be positive\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/triviaqa/inputs.py","lineNumber":108,"sourceCode":"\n  Args:\n    tensor: A Tensor with rank >= 1 to pad.\n    factor: Positive integer factor to pad for. If a Tensor, must be a scalar\n      int.\n    axis: A valid axis in `tensor` to pad.\n    mode: The padding mode to use according to `tf.pad`. Defaults to 'CONSTANT'.\n    constant_values: For 'CONSTANT' mode, the scalar pad value to use within\n      `tf.pad`. Defaults to 0. Must be same type as `tensor`.\n    name: A name for the operation (optional).\n\n  Returns:\n    The padded Tensor result.\n  \"\"\"\n  with tf.name_scope(name or 'pad_to_multiple'):\n    tensor = tf.convert_to_tensor(tensor)\n\n    if isinstance(factor, int) and factor < 1:\n      raise ValueError('`factor` must be positive.')\n    rank = tensor.shape.rank\n    if rank is None:\n      raise ValueError('Static rank of `tensor` must be known.')\n    if axis < 0:\n      axis += rank\n    if axis < 0 or axis >= rank:\n      raise ValueError('`axis` out of bounds for `tensor` rank.')\n\n    axis_len = tf_utils.get_shape_list(tensor)[axis]\n    pad_len = -axis_len % factor\n    paddings = pad_len * tf.one_hot([-1, axis], rank, axis=0, dtype=tf.int32)\n    return tf.pad(\n        tensor=tensor,\n        paddings=paddings,\n        mode=mode,\n        constant_values=constant_values)\n\n","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/triviaqa/inputs.py#L90-L126","documentation":"Error \"`factor` must be positive.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/triviaqa/inputs.py:108 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"}