tensorflow/models · error · ValueError
context_level should be specified as odd number.
Error message
context_level should be specified as odd number.
What it means
Error "context_level should be specified as odd number." thrown in tensorflow/models.
Source
Thrown at official/projects/const_cl/modeling/heads/instance_reconstructor.py:117
4, use_bias=True, activation='relu', name='temporal_mlp_l1'),
tf_keras.layers.Dense(
8, use_bias=True, name='temporal_mlp_l2')]
self._attention_decoder = transformer_decoder.TransformerDecoder(
num_channels=num_tx_channels,
num_layers=num_tx_layers,
num_heads=num_tx_heads,
use_bias=use_bias,
activation=activation,
dropout_rate=dropout_rate,
layer_norm_epsilon=layer_norm_epsilon)
self._projection_layer = tf_keras.layers.Dense(num_output_channels)
def _get_memory_embeddings(self, inputs: tf.Tensor) -> tf.Tensor:
"""Uniformly samples frames to construct memory embeddings."""
if self._context_level % 2 == 0:
raise ValueError('context_level should be specified as odd number.')
num_frames = tf.shape(inputs)[1]
keyframe_index = num_frames // 2
stride = num_frames // self._context_level
start = self._context_level // 2 * -1
stop = self._context_level // 2 + 1 # exclusive
memories = []
for idx in range(start, stop):
idx = idx * stride + keyframe_index
memories.append(inputs[:, idx, ...])
memories = tf.stack(memories, axis=1)
return memories
def _add_positional_embedding(self, inputs: tf.Tensor) -> tf.Tensor:
"""Adds positional embeddings to the inputs tensor."""
# Compute the locations using meshgrid.View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/projects/const_cl/modeling/heads/instance_reconstructor.py:117 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/a6ee189300ff3dcd.
Report an issue: GitHub.