{"record":{"id":"603e1161731eee75","repo":"tensorflow/models","slug":"translations-rank-must-be-statically-known","errorCode":null,"errorMessage":"translations rank must be statically known","messagePattern":"translations rank must be statically known","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"official/legacy/image_classification/augment.py","lineNumber":101,"sourceCode":"     [0 0 1]]\n\n  Args:\n    translations: The 2-element list representing [dx, dy], or a matrix of\n      2-element lists representing [dx dy] to translate for each image. The\n      shape must be static.\n\n  Returns:\n    The transformation matrix of shape (num_images, 8).\n\n  Raises:\n    `TypeError` if\n      - the shape of `translations` is not known or\n      - the shape of `translations` is not rank 1 or 2.\n\n  \"\"\"\n  translations = tf.convert_to_tensor(translations, dtype=tf.float32)\n  if translations.get_shape().ndims is None:\n    raise TypeError('translations rank must be statically known')\n  elif len(translations.get_shape()) == 1:\n    translations = translations[None]\n  elif len(translations.get_shape()) != 2:\n    raise TypeError('translations should have rank 1 or 2.')\n  num_translations = tf.shape(translations)[0]\n\n  return tf.concat(\n      values=[\n          tf.ones((num_translations, 1), tf.dtypes.float32),\n          tf.zeros((num_translations, 1), tf.dtypes.float32),\n          -translations[:, 0, None],\n          tf.zeros((num_translations, 1), tf.dtypes.float32),\n          tf.ones((num_translations, 1), tf.dtypes.float32),\n          -translations[:, 1, None],\n          tf.zeros((num_translations, 2), tf.dtypes.float32),\n      ],\n      axis=1,\n  )","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/legacy/image_classification/augment.py#L83-L119","documentation":"Static-shape guard in _convert_translation_to_transform: the translations tensor's rank is unknown at graph-construction time (ndims is None). Translation augmentation requires a statically known shape to build the (num_images, 8) transform matrices.","triggerScenarios":"Thrown at official/legacy/image_classification/augment.py:101 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass translations with a statically known shape (set_shape or concrete constants)","Avoid feeding dynamic-shaped tensors from datasets without static shapes into translate()"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}