{"record":{"id":"0577c006a899316e","repo":"tensorflow/models","slug":"only-support-expanding-the-first-or-the-last-dimen","errorCode":null,"errorMessage":"Only support expanding the first or the last dimension. Got: {}","messagePattern":"Only support expanding the first or the last dimension\\. Got: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/modeling/fast_training/experimental/tf2_utils_2x_wide.py","lineNumber":60,"sourceCode":"  matmul(x, w) ==\n      matmul(expand_vector(x), expand_1_axis(w, axis=0))\n\n  If `axis = -1` and `epsilon = 0.0`, the following constraint will be\n  satisfied:\n  expand_vector(matmul(x, w)) ==\n      2 * matmul(x, expand_1_axis(w, epsilon=0.0, axis=-1))\n\n  Args:\n    w: Numpy array of shape [a_0, a_1, ..., a_i-1, a_i].\n    epsilon: Symmetric Noise added to expanded tensor.\n    axis: Must be either 0 or -1.\n\n  Returns:\n    Expanded numpy array.\n  \"\"\"\n\n  if axis not in (0, -1):\n    raise ValueError(\n        \"Only support expanding the first or the last dimension. \"\n        \"Got: {}\".format(axis)\n    )\n\n  rank = len(w.shape)\n\n  d_w = np.random.normal(np.zeros_like(w), np.fabs(w) * epsilon, w.shape)\n  d_w = np.repeat(d_w, 2, axis=axis)\n\n  sign_flip = np.array([1, -1])\n  for _ in range(rank - 1):\n    sign_flip = np.expand_dims(sign_flip, axis=axis - 1)\n  sign_flip = np.tile(sign_flip,\n                      [w.shape[0]] + [1] * (rank - 2) + [w.shape[-1]])\n\n  d_w *= sign_flip\n  w_expand = (np.repeat(w, 2, axis=axis) + d_w) / 2\n  return w_expand","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/modeling/fast_training/experimental/tf2_utils_2x_wide.py#L42-L78","documentation":"Error \"Only support expanding the first or the last dimension. Got: {}\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/modeling/fast_training/experimental/tf2_utils_2x_wide.py:60 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"}