Error iterating over Dataset with DataLoader
{'login': 'EvanZ', 'id': 1295082, 'node_id': 'MDQ6VXNlcjEyOTUwODI=', 'avatar_url': 'https://avatars.githubusercontent.com/u/1295082?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/EvanZ', 'html_url': 'https://github.com/EvanZ', 'followers_url': 'https://api.github.com/users/EvanZ/followers', 'following_url': 'https://api.github.com/users/EvanZ/following{/other_user}', 'gists_url': 'https://api.github.com/users/EvanZ/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/EvanZ/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/EvanZ/subscriptions', 'organizations_url': 'https://api.github.com/users/EvanZ/orgs', 'repos_url': 'https://api.github.com/users/EvanZ/repos', 'events_url': 'https://api.github.com/users/EvanZ/events{/privacy}', 'received_events_url': 'https://api.github.com/users/EvanZ/received_events', 'type': 'User', 'site_admin': False}
[]
[]
['Instead of:\r\n```python\r\ndataloader = torch.utils.data.DataLoader(encoded_dataset, batch_sampler=32)\r\n```\r\nIt should be:\r\n```python\r\ndataloader = torch.utils.data.DataLoader(encoded_dataset, batch_size=32)\r\n```\r\n\r\n`batch_sampler` accepts a Sampler object or an Iterable, so you get an error.'
 "@mariosasko I thought that would fix it, but now I'm getting a different error:\r\n\r\n```\r\n/usr/local/lib/python3.6/dist-packages/datasets/arrow_dataset.py:851: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at  /pytorch/torch/csrc/utils/tensor_numpy.cpp:141.)\r\n  return torch.tensor(x, **format_kwargs)\r\n---------------------------------------------------------------------------\r\nRuntimeError                              Traceback (most recent call last)\r\n<ipython-input-20-3af1d82bf93a> in <module>()\r\n      1 dataloader = torch.utils.data.DataLoader(encoded_dataset, batch_size=32)\r\n----> 2 next(iter(dataloader))\r\n\r\n5 frames\r\n/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/collate.py in default_collate(batch)\r\n     53             storage = elem.storage()._new_shared(numel)\r\n     54             out = elem.new(storage)\r\n---> 55         return torch.stack(batch, 0, out=out)\r\n     56     elif elem_type.__module__ == 'numpy' and elem_type.__name__ != 'str_' \\\r\n     57             and elem_type.__name__ != 'string_':\r\n\r\nRuntimeError: stack expects each tensor to be equal size, but got [7] at entry 0 and [10] at entry 1\r\n```\r\n\r\nAny thoughts what this means?I Do I need padding?"
 'Yes, padding is an answer. \r\n\r\nThis can be solved easily by passing a callable to the collate_fn arg of DataLoader that adds padding. '
 'Padding was the fix, thanks!'
 'dataloader = torch.utils.data.DataLoader(encoded_dataset, batch_size=4)\r\nbatch = next(iter(dataloader))\r\n\r\ngetting \r\nValueError: cannot reshape array of size 8192 into shape (1,512,4)\r\n\r\nI had put padding as 2048 for encoded_dataset\r\nkindly help']
I have a Dataset that I've mapped a tokenizer over:

```
encoded_dataset.set_format(type='torch',columns=['attention_mask','input_ids','token_type_ids'])
encoded_dataset[:1]
```
```
{'attention_mask': tensor([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]),
 'input_ids': tensor([[  101,   178,  1198,  1400,  1714, 22233, 21365,  4515,  8618,  1113,
            102]]),
 'token_type_ids': tensor([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])}
```

When I try to iterate as in the docs, I get errors:

```
dataloader = torch.utils.data.DataLoader(encoded_dataset, batch_sampler=32)
next(iter(dataloader))
```

```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-45-05180ba8aa35> in <module>()
      1 dataloader = torch.utils.data.DataLoader(encoded_dataset, batch_sampler=32)
----> 2 next(iter(dataloader))

3 frames
/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in __init__(self, loader)
    411         self._timeout = loader.timeout
    412         self._collate_fn = loader.collate_fn
--> 413         self._sampler_iter = iter(self._index_sampler)
    414         self._base_seed = torch.empty((), dtype=torch.int64).random_(generator=loader.generator).item()
    415         self._persistent_workers = loader.persistent_workers

TypeError: 'int' object is not iterable


```
{'url': 'https://api.github.com/repos/huggingface/datasets/issues/1765/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}