Array2D(shape=(2, None), ...) is not supported

#1
by lhoestq HF staff - opened

In Array2D, only the first dimension can be None. Right now using shape=(2, None) you can experience issues when accessing elements; it's likely going to give you errors.

Can you check when happens if you access one element ? It's maybe possible in datasets to support having the unknown size to be at an arbitrary position in the shape, not just in the first position. It happens here in datasets:

https://github.com/huggingface/datasets/blob/b44016b430b4fbd8ef63a246da067a7d8e47231d/src/datasets/features/features.py#L674-L689

Thank you for reading the script with a keen eye!

Absolutely! I can confirm that I can display these elements without getting an error:

from datasets import load_dataset

ds_name = "HuggingFaceM4/Caltech-101" 
ds = load_dataset(ds_name, 'without_background_category', use_auth_token=True)

print(ds["train"][0]['annotation']['obj_contour'])
print(ds["test"][0]['annotation']['obj_contour'])

I've just done several tests and I don't seem to be encountering any errors. It seems that in the "train" split the "None" dimension is always 51 and for the "test" split 31.

Thanks ! This means that this works without being officially supported then lol.

If you plan to rely on this feature, maybe it would be worth adding tests in datasets to make sure it keeps working in the long run. Let me know if you plan to rely on this feature

Sign up or log in to comment