Open cheulyop opened 3 years ago
The error seems to occur while running the below lines. https://github.com/tensorflow/datasets/blob/c6745749bbbe3041e96176f51538085c77fcac4f/tensorflow_datasets/core/features/audio_feature.py#L78-L82
If audio has channels > 1, then audio_data
is reshaped accordingly, but the shape of what is being referenced by super()
remains (None,)
, thus the mismatch.
I'm getting around this by setting audio channels to mono(1) before it checks for the matching shape/rank, but could there be a better way, i.e., to update the shape of the parent class?
I tried creating the base class tensorflow_datasets.core.features.Tensor
and using its encode_example
directly, but it didn't help and gave me another error instead.
File "/home/admin/.miniconda3/envs/tf/bin/tfds", line 10, in <module>
sys.exit(launch_cli())
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/scripts/cli/main.py", line 126, in launch_cli
app.run(main, flags_parser=_parse_flags)
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/absl/app.py", line 303, in run
_run_main(main, args)
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/scripts/cli/main.py", line 121, in main
args.subparser_fn(args)
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/scripts/cli/build.py", line 199, in _build_datasets
_download_and_prepare(args, builder)
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/scripts/cli/build.py", line 355, in _download_and_prepare
builder.download_and_prepare(
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/core/dataset_builder.py", line 439, in download_and_prepare
self._download_and_prepare(
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/core/dataset_builder.py", line 1155, in _download_and_prepare
split_info_futures = [
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/core/dataset_builder.py", line 1156, in <listcomp>
split_builder.submit_split_generation( # pylint: disable=g-complex-comprehension
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/core/split_builder.py", line 291, in submit_split_generation
return self._build_from_generator(**build_kwargs)
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/core/split_builder.py", line 362, in _build_from_generator
writer.write(key, example)
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/core/tfrecords_writer.py", line 273, in write
serialized_example = self._serializer.serialize_example(example)
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/core/example_serializer.py", line 52, in serialize_example
example = _dict_to_tf_example(example, self._flat_example_specs)
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/core/example_serializer.py", line 89, in _dict_to_tf_example
example_dict = {
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/core/example_serializer.py", line 90, in <dictcomp>
k: run_with_reraise(_item_to_tf_feature, k, item, tensor_info)
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/core/example_serializer.py", line 70, in run_with_reraise
utils.reraise(
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/core/example_serializer.py", line 68, in run_with_reraise
return fn(example_data, tensor_info)
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/core/example_serializer.py", line 129, in _item_to_tf_feature
v = _item_to_np_array(item, shape=tensor_info.shape, dtype=tensor_info.dtype)
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/core/example_serializer.py", line 120, in _item_to_np_array
utils.assert_shape_match(item.shape, shape)
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow_datasets/core/utils/tf_utils.py", line 145, in assert_shape_match
shape1.assert_same_rank(shape2)
File "/home/admin/.miniconda3/envs/tf/lib/python3.9/site-packages/tensorflow/python/framework/tensor_shape.py", line 1001, in assert_same_rank
raise ValueError("Shapes %s and %s must have the same rank" %
ValueError: Error while serializing feature `audio`: `TensorInfo(shape=(None,), dtype=tf.int64)`: Shapes (1922688, 2) and (None,) must have the same rank
Any help would be much appreciated.
Same here. Is there any workaround?
Short description There's an error when loading the Dementiabank dataset, although manually downloaded files are in the correct directory.
Environment information
Operating System: Ubuntu 18.04
Python version: 3.8.10
tensorflow-datasets
/tfds-nightly
version: 4.3.0tensorflow
/tf-nightly
version: 2.4.1Does the issue still exists with the last
tfds-nightly
package (pip install --upgrade tfds-nightly
) ? - YesReproduction instructions
Link to logs
Expected behavior Dataset loads.
Additional context Add any other context about the problem here.