{"record":{"id":"91adc7ee40f3a828","repo":"tensorflow/models","slug":"number-of-embedding-features-num-pos-features-mu-91adc7","errorCode":null,"errorMessage":"Number of embedding features (num_pos_features) must be even when column and row embeddings are concatenated.","messagePattern":"Number of embedding features \\(num_pos_features\\) must be even when column and row embeddings are concatenated\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/mae/modeling/utils.py","lineNumber":49,"sourceCode":"    attention_mask: a `bool` Tensor specifying the size of the input image to\n      the Transformer and which elements are padded, of size [batch_size,\n      height, width]\n    num_pos_features: a `int` specifying the number of positional features,\n      should be equal to the hidden size of the Transformer network\n    temperature: a `float` specifying the temperature of the positional\n      embedding. Any type that is converted to a `float` can also be accepted.\n    normalize: a `bool` determining whether the positional embeddings should be\n      normalized between [0, scale] before application of the sine and cos\n      functions.\n    scale: a `float` if normalize is True specifying the scale embeddings before\n      application of the embedding function.\n\n  Returns:\n    embeddings: a `float` tensor of the same shape as input_tensor specifying\n      the positional embeddings based on sine features.\n  \"\"\"\n  if num_pos_features % 2 != 0:\n    raise ValueError(\n        \"Number of embedding features (num_pos_features) must be even when \"\n        \"column and row embeddings are concatenated.\")\n  num_pos_features = num_pos_features // 2\n\n  # Produce row and column embeddings based on total size of the image\n  # <tf.float>[batch_size, height, width]\n  attention_mask = tf.cast(attention_mask, tf.float32)\n  row_embedding = tf.cumsum(attention_mask, 1)\n  col_embedding = tf.cumsum(attention_mask, 2)\n\n  if normalize:\n    eps = 1e-6\n    row_embedding = row_embedding / (row_embedding[:, -1:, :] + eps) * scale\n    col_embedding = col_embedding / (col_embedding[:, :, -1:] + eps) * scale\n\n  dim_t = tf.range(num_pos_features, dtype=row_embedding.dtype)\n  dim_t = tf.pow(temperature, 2 * (dim_t // 2) / num_pos_features)\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/mae/modeling/utils.py#L31-L67","documentation":"Error \"Number of embedding features (num_pos_features) must be even when column and row embeddings are concatenated.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/mae/modeling/utils.py:49 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"}