TypeError: new(): invalid data type 'numpy.str_'
Facing the below error while running 
```
# Setting up training
trainer = Seq2SeqTrainer(
    model=model,
    args=args,
    train_dataset=tokenized_datasets['train'],
    eval_dataset=tokenized_datasets['validation'],
)

```
on Kaggle Notebooks; while the same code runs fine in Colab Notebooks. 

Below is the error log.



> ```
> ---------------------------------------------------------------------------
> TypeError                                 Traceback (most recent call last)
> <ipython-input-23-e9826d90c0df> in <module>
>       1 # This will take around 20-25 minutes
> ----> 2 trainer.train()
> 
> /opt/conda/lib/python3.7/site-packages/transformers/trainer.py in train(self, resume_from_checkpoint, trial, **kwargs)
>    1032             self.control = self.callback_handler.on_epoch_begin(self.args, self.state, self.control)
>    1033 
> -> 1034             for step, inputs in enumerate(epoch_iterator):
>    1035 
>    1036                 # Skip past any already trained steps if resuming training
> 
> /opt/conda/lib/python3.7/site-packages/torch/utils/data/dataloader.py in __next__(self)
>     433         if self._sampler_iter is None:
>     434             self._reset()
> --> 435         data = self._next_data()
>     436         self._num_yielded += 1
>     437         if self._dataset_kind == _DatasetKind.Iterable and \
> 
> /opt/conda/lib/python3.7/site-packages/torch/utils/data/dataloader.py in _next_data(self)
>     473     def _next_data(self):
>     474         index = self._next_index()  # may raise StopIteration
> --> 475         data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
>     476         if self._pin_memory:
>     477             data = _utils.pin_memory.pin_memory(data)
> 
> /opt/conda/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py in fetch(self, possibly_batched_index)
>      42     def fetch(self, possibly_batched_index):
>      43         if self.auto_collation:
> ---> 44             data = [self.dataset[idx] for idx in possibly_batched_index]
>      45         else:
>      46             data = self.dataset[possibly_batched_index]
> 
> /opt/conda/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py in <listcomp>(.0)
>      42     def fetch(self, possibly_batched_index):
>      43         if self.auto_collation:
> ---> 44             data = [self.dataset[idx] for idx in possibly_batched_index]
>      45         else:
>      46             data = self.dataset[possibly_batched_index]
> 
> /opt/conda/lib/python3.7/site-packages/datasets/arrow_dataset.py in __getitem__(self, key)
>    1482             format_columns=self._format_columns,
>    1483             output_all_columns=self._output_all_columns,
> -> 1484             format_kwargs=self._format_kwargs,
>    1485         )
>    1486 
> 
> /opt/conda/lib/python3.7/site-packages/datasets/arrow_dataset.py in _getitem(self, key, format_type, format_columns, output_all_columns, format_kwargs)
>    1471         pa_subtable = query_table(self._data, key, indices=self._indices if self._indices is not None else None)
>    1472         formatted_output = format_table(
> -> 1473             pa_subtable, key, formatter=formatter, format_columns=format_columns, output_all_columns=output_all_columns
>    1474         )
>    1475         return formatted_output
> 
> /opt/conda/lib/python3.7/site-packages/datasets/formatting/formatting.py in format_table(table, key, formatter, format_columns, output_all_columns)
>     417     else:
>     418         pa_table_to_format = pa_table.drop(col for col in pa_table.column_names if col not in format_columns)
> --> 419         formatted_output = formatter(pa_table_to_format, query_type=query_type)
>     420         if output_all_columns:
>     421             if isinstance(formatted_output, MutableMapping):
> 
> /opt/conda/lib/python3.7/site-packages/datasets/formatting/formatting.py in __call__(self, pa_table, query_type)
>     189     def __call__(self, pa_table: pa.Table, query_type: str) -> Union[RowFormat, ColumnFormat, BatchFormat]:
>     190         if query_type == "row":
> --> 191             return self.format_row(pa_table)
>     192         elif query_type == "column":
>     193             return self.format_column(pa_table)
> 
> /opt/conda/lib/python3.7/site-packages/datasets/formatting/torch_formatter.py in format_row(self, pa_table)
>      57     def format_row(self, pa_table: pa.Table) -> dict:
>      58         row = self.numpy_arrow_extractor().extract_row(pa_table)
> ---> 59         return self.recursive_tensorize(row)
>      60 
>      61     def format_column(self, pa_table: pa.Table) -> "torch.Tensor":
> 
> /opt/conda/lib/python3.7/site-packages/datasets/formatting/torch_formatter.py in recursive_tensorize(self, data_struct)
>      53 
>      54     def recursive_tensorize(self, data_struct: dict):
> ---> 55         return map_nested(self._recursive_tensorize, data_struct, map_list=False)
>      56 
>      57     def format_row(self, pa_table: pa.Table) -> dict:
> 
> /opt/conda/lib/python3.7/site-packages/datasets/utils/py_utils.py in map_nested(function, data_struct, dict_only, map_list, map_tuple, map_numpy, num_proc, types)
>     202     if num_proc <= 1 or len(iterable) <= num_proc:
>     203         mapped = [
> --> 204             _single_map_nested((function, obj, types, None, True)) for obj in tqdm(iterable, disable=disable_tqdm)
>     205         ]
>     206     else:
> 
> /opt/conda/lib/python3.7/site-packages/datasets/utils/py_utils.py in <listcomp>(.0)
>     202     if num_proc <= 1 or len(iterable) <= num_proc:
>     203         mapped = [
> --> 204             _single_map_nested((function, obj, types, None, True)) for obj in tqdm(iterable, disable=disable_tqdm)
>     205         ]
>     206     else:
> 
> /opt/conda/lib/python3.7/site-packages/datasets/utils/py_utils.py in _single_map_nested(args)
>     140     # Singleton first to spare some computation
>     141     if not isinstance(data_struct, dict) and not isinstance(data_struct, types):
> --> 142         return function(data_struct)
>     143 
>     144     # Reduce logging to keep things readable in multiprocessing with tqdm
> 
> /opt/conda/lib/python3.7/site-packages/datasets/formatting/torch_formatter.py in _recursive_tensorize(self, data_struct)
>      50             if data_struct.dtype == np.object:  # pytorch tensors cannot be instantied from an array of objects
>      51                 return [self.recursive_tensorize(substruct) for substruct in data_struct]
> ---> 52         return self._tensorize(data_struct)
>      53 
>      54     def recursive_tensorize(self, data_struct: dict):
> 
> /opt/conda/lib/python3.7/site-packages/datasets/formatting/torch_formatter.py in _tensorize(self, value)
>      42             default_dtype = {"dtype": torch.float32}
>      43 
> ---> 44         return torch.tensor(value, **{**default_dtype, **self.torch_tensor_kwargs})
>      45 
>      46     def _recursive_tensorize(self, data_struct: dict):
> 
> TypeError: new(): invalid data type 'numpy.str_'
> ```
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.<|||||>Hi @pn12 - the issue is likely that you have columns that are strings (not encoded). Make sure to drop all columns that aren't encoded and pass the new object to the model.