tensorflow/models · error · ValueError

Unrecongized dtype

Error message

Unrecongized dtype: {dtype}

What it means

Raised in save_to_tfrecord when an output state tensor's dtype is neither tf.int32 nor tf.float32 while serializing MoViNet stateful RNN states to TFRecord features. Only int32 and float32 state tensors have supported converter paths; any other dtype (e.g. bfloat16, float64, bool) fires this error.

Solutions

  1. Inspect output_states to find which key has a non-int32/float32 dtype
  2. Cast the offending state tensor to tf.float32 before serialization
  3. Extend the branch chain with a case for the actual dtype
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at official/projects/movinet/tools/quantize_movinet.py:140 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/297ca4c909000d8d. Report an issue: GitHub.

Appendix: source

Thrown at official/projects/movinet/tools/quantize_movinet.py:140

  image_string = tf.io.encode_png(
      tf.squeeze(tf.cast(input_frame * 255., tf.uint8), axis=[0, 1]))
  features['image'] = _bytes_feature(image_string.numpy())

  # Input/Output states at time T
  for k, v in output_states.items():
    dtype = v[0].dtype
    if dtype == tf.int32:
      features['input/' + k] = _int64_feature(
          input_states[k].numpy().flatten().tolist())
      features['output/' + k] = _int64_feature(
          output_states[k].numpy().flatten().tolist())
    elif dtype == tf.float32:
      features['input/' + k] = _float_feature(
          input_states[k].numpy().flatten().tolist())
      features['output/' + k] = _float_feature(
          output_states[k].numpy().flatten().tolist())
    else:
      raise ValueError(f'Unrecongized dtype: {dtype}')

  tfe = _build_tf_example(features)
  record_file = '{}/movinet_stream_{:06d}.tfrecords'.format(
      output_dataset_dir, file_index)
  logging.info('Saving to %s.', record_file)
  with tf.io.TFRecordWriter(record_file) as writer:
    writer.write(tfe)


def get_dataset() -> tf.data.Dataset:
  """Gets dataset source."""
  config = video_classification_configs.video_classification_kinetics600()

  temporal_stride = FLAGS.temporal_stride
  num_frames = FLAGS.num_frames
  image_size = FLAGS.image_size
  feature_shape = (num_frames, image_size, image_size, 3)

View on GitHub (pinned to e006f5f0d5)