# Longformer Tensorflow Int32 vs Int64 error

**URL:** <https://discuss.huggingface.co/t/longformer-tensorflow-int32-vs-int64-error/22503>\
**Category:** Models\
**Created:** [September 4, 2022, 6:27am UTC](https://discuss.huggingface.co/t/longformer-tensorflow-int32-vs-int64-error/22503 "2022-09-04T06:27:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![uniflow](https://avatars.discourse-cdn.com/v4/letter/u/a8b319/32.png) [@uniflow](https://discuss.huggingface.co/u/uniflow)\
**Post date:** [September 4, 2022, 6:27am UTC](https://discuss.huggingface.co/t/longformer-tensorflow-int32-vs-int64-error/22503/1 "2022-09-04T06:27:26Z")

</div>

I am trying an example of fine-tuning longformer and got the error of

`TypeError: Input 'updates' of 'TensorScatterUpdate' Op has type int32 that does not match type int64 of argument 'tensor'.`

Not sure what’s going on. Here is my code example. Any help would be great. Thank you very much!

```auto

from transformers import LongformerTokenizer, TFLongformerForSequenceClassification
from datasets import Dataset

import tensorflow as tf
import pickle
import numpy as np

tokenizer = LongformerTokenizerFast.from_pretrained('allenai/longformer-base-4096')
model = TFLongformerForSequenceClassification.from_pretrained('allenai/longformer-base-4096', num_labels=2, gradient_checkpointing=True)
model.compile(
optimizer=tf.keras.optimizers.Adam(learning_rate=5e-5),
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
metrics=tf.metrics.SparseCategoricalAccuracy(),
)

my_dict = {'text': ["random text 1", "random text 2", "random text 3"],
'label': np.array([0, 0, 1], dtype=np.int64)}

dataset = Dataset.from_dict(my_dict)

tokenizer = LongformerTokenizer.from_pretrained('allenai/longformer-base-4096')

def tokenize_function(examples):
return tokenizer(examples["text"], padding="max_length", truncation=True)

tokenized_datasets = dataset.map(tokenize_function, batched=True)

small_train_dataset = tokenized_datasets.shuffle(seed=42)

from transformers import DefaultDataCollator

data_collator = DefaultDataCollator(return_tensors="tf")

tf_train_dataset = small_train_dataset.to_tf_dataset(
columns=["attention_mask", "input_ids", "token_type_ids"],
label_cols=["labels"],
shuffle=True,
collate_fn=data_collator,
batch_size=8,
)

model.fit(tf_train_dataset, batch_size=1)

```
