{"record":{"id":"a6ee189300ff3dcd","repo":"tensorflow/models","slug":"context-level-should-be-specified-as-odd-number","errorCode":null,"errorMessage":"context_level should be specified as odd number.","messagePattern":"context_level should be specified as odd number\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/const_cl/modeling/heads/instance_reconstructor.py","lineNumber":117,"sourceCode":"              4, use_bias=True, activation='relu', name='temporal_mlp_l1'),\n          tf_keras.layers.Dense(\n              8, use_bias=True, name='temporal_mlp_l2')]\n\n    self._attention_decoder = transformer_decoder.TransformerDecoder(\n        num_channels=num_tx_channels,\n        num_layers=num_tx_layers,\n        num_heads=num_tx_heads,\n        use_bias=use_bias,\n        activation=activation,\n        dropout_rate=dropout_rate,\n        layer_norm_epsilon=layer_norm_epsilon)\n\n    self._projection_layer = tf_keras.layers.Dense(num_output_channels)\n\n  def _get_memory_embeddings(self, inputs: tf.Tensor) -> tf.Tensor:\n    \"\"\"Uniformly samples frames to construct memory embeddings.\"\"\"\n    if self._context_level % 2 == 0:\n      raise ValueError('context_level should be specified as odd number.')\n\n    num_frames = tf.shape(inputs)[1]\n    keyframe_index = num_frames // 2\n    stride = num_frames // self._context_level\n    start = self._context_level // 2 * -1\n    stop = self._context_level // 2 + 1  # exclusive\n\n    memories = []\n    for idx in range(start, stop):\n      idx = idx * stride + keyframe_index\n      memories.append(inputs[:, idx, ...])\n\n    memories = tf.stack(memories, axis=1)\n    return memories\n\n  def _add_positional_embedding(self, inputs: tf.Tensor) -> tf.Tensor:\n    \"\"\"Adds positional embeddings to the inputs tensor.\"\"\"\n    # Compute the locations using meshgrid.","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/const_cl/modeling/heads/instance_reconstructor.py#L99-L135","documentation":"Error \"context_level should be specified as odd number.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/const_cl/modeling/heads/instance_reconstructor.py:117 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"}