{"record":{"id":"7aad05187ffc62d8","repo":"tensorflow/models","slug":"angles-should-have-a-rank-0-or-1-7aad05","errorCode":null,"errorMessage":"Angles should have a rank 0 or 1.","messagePattern":"Angles should have a rank 0 or 1\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"official/vision/ops/augment.py","lineNumber":347,"sourceCode":"\n  Args:\n    angles: A scalar to rotate all images, or a vector to rotate a batch of\n      images. This must be a scalar.\n    image_width: The width of the image(s) to be transformed.\n    image_height: The height of the image(s) to be transformed.\n\n  Returns:\n    A tensor of shape (num_images, 8).\n\n  Raises:\n    `TypeError` if `angles` is not rank 0 or 1.\n\n  \"\"\"\n  angles = tf.convert_to_tensor(angles, dtype=tf.float32)\n  if len(angles.get_shape()) == 0:  # pylint:disable=g-explicit-length-test\n    angles = angles[None]\n  elif len(angles.get_shape()) != 1:\n    raise TypeError('Angles should have a rank 0 or 1.')\n  x_offset = ((image_width - 1) -\n              (tf.math.cos(angles) * (image_width - 1) - tf.math.sin(angles) *\n               (image_height - 1))) / 2.0\n  y_offset = ((image_height - 1) -\n              (tf.math.sin(angles) * (image_width - 1) + tf.math.cos(angles) *\n               (image_height - 1))) / 2.0\n  num_angles = tf.shape(angles)[0]\n  return tf.concat(\n      values=[\n          tf.math.cos(angles)[:, None],\n          -tf.math.sin(angles)[:, None],\n          x_offset[:, None],\n          tf.math.sin(angles)[:, None],\n          tf.math.cos(angles)[:, None],\n          y_offset[:, None],\n          tf.zeros((num_angles, 2), tf.dtypes.float32),\n      ],\n      axis=1,","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/ops/augment.py#L329-L365","documentation":"Error \"Angles should have a rank 0 or 1.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/ops/augment.py:347 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass angles as a scalar (rank 0) or a 1-D tensor (rank 1).","Squeeze higher-rank angle tensors before calling the augmentation."],"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"}