{"record":{"id":"db4698e65f312ac6","repo":"tensorflow/models","slug":"wrong-shape-detected-for-custom-policy-expected","errorCode":null,"errorMessage":"Wrong shape detected for custom policy. Expected (:, :, 3) but got {}.","messagePattern":"Wrong shape detected for custom policy\\. Expected \\(:, :, 3\\) but got (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/ops/augment.py","lineNumber":2006,"sourceCode":"      self.policies = self.available_policies[augmentation_name]\n\n    else:\n      self._check_policy_shape(policies)\n      self.policies = policies\n\n  def _check_policy_shape(self, policies):\n    \"\"\"Checks dimension and shape of the custom policy.\n\n    Args:\n      policies: List of list of tuples in the form `(func, prob, level)`. Must\n        have shape of `(:, :, 3)`.\n\n    Raises:\n      ValueError if the shape of `policies` is unexpected.\n    \"\"\"\n    in_shape = np.array(policies).shape\n    if len(in_shape) != 3 or in_shape[-1:] != (3,):\n      raise ValueError('Wrong shape detected for custom policy. Expected '\n                       '(:, :, 3) but got {}.'.format(in_shape))\n\n  def _make_tf_policies(self):\n    \"\"\"Prepares the TF functions for augmentations based on the policies.\"\"\"\n    replace_value = [128] * 3\n\n    # func is the string name of the augmentation function, prob is the\n    # probability of applying the operation and level is the parameter\n    # associated with the tf op.\n\n    # tf_policies are functions that take in an image and return an augmented\n    # image.\n    tf_policies = []\n    for policy in self.policies:\n      tf_policy = []\n      assert_ranges = []\n      # Link string name to the correct python function and make sure the\n      # correct argument is passed into that function.","sourceCodeStart":1988,"sourceCodeEnd":2024,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/ops/augment.py#L1988-L2024","documentation":"Error \"Wrong shape detected for custom policy. Expected (:, :, 3) but got {}.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/ops/augment.py:2006 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Shape the custom policy array as (:, :, 3): each sub-policy is a list of (op, prob, magnitude) triples.","Fix the custom policy structure so every operation entry has exactly 3 elements."],"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"}