# Can't convert non-rectangular Python sequence to Tensor. Fine tuning model with custome data

**URL:** <https://discuss.huggingface.co/t/cant-convert-non-rectangular-python-sequence-to-tensor-fine-tuning-model-with-custome-data/24904>\
**Category:** 🤗Transformers\
**Created:** [October 24, 2022, 9:36pm UTC](https://discuss.huggingface.co/t/cant-convert-non-rectangular-python-sequence-to-tensor-fine-tuning-model-with-custome-data/24904 "2022-10-24T21:36:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maaz66](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/maaz66/32/12219_2.png) [@Maaz66](https://discuss.huggingface.co/u/Maaz66)\
**Post date:** [October 24, 2022, 9:36pm UTC](https://discuss.huggingface.co/t/cant-convert-non-rectangular-python-sequence-to-tensor-fine-tuning-model-with-custome-data/24904/1 "2022-10-24T21:36:50Z")

</div>

This is the code and Im getting this weird error, I dont know why its happening

```auto
from datasets import load_dataset, Dataset

dataset = load_dataset("go_emotions")

train_text = dataset['train']['text']
test_text = dataset['test']['text']
val_text = dataset['validation']['text']
train_labels = dataset['train']['labels']
test_labels = dataset['test']['labels']
val_labels = dataset['validation']['labels']

from transformers import DistilBertTokenizerFast
tokenizer = DistilBertTokenizerFast.from_pretrained('distilbert-base-uncased')

train_encodings = tokenizer(train_text, padding='max_length')
val_encodings = tokenizer(val_text, padding='max_length')
test_encodings = tokenizer(test_text, padding='max_length')

import tensorflow as tf

train_dataset = tf.data.Dataset.from_tensor_slices((
    dict(train_encodings),
    train_labels
))
val_dataset = tf.data.Dataset.from_tensor_slices((
    dict(val_encodings),
    val_labels
))
test_dataset = tf.data.Dataset.from_tensor_slices((
    dict(test_encodings),
    test_labels
))

```
