# Kernel died when fine-tune a pretrained model using keras

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fkernel-died-when-fine-tune-a-pretrained-model-using-keras%2F60082%3E%5C
**Category:** Beginners\
**Created:** [October 26, 2023, 8:41pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fkernel-died-when-fine-tune-a-pretrained-model-using-keras%2F60082 "2023-10-26T20:41:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lilly11](https://avatars.discourse-cdn.com/v4/letter/l/da6949/32.png) [@Lilly11](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FLilly11)%5C
**Post date:** [October 26, 2023, 8:41pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fkernel-died-when-fine-tune-a-pretrained-model-using-keras%2F60082%2F1 "2023-10-26T20:41:32Z")

</div>

I am following the hugging face tutorial to fine-tune a BERT model for sequence classification on the CoLA (Corpus of Linguistic Acceptability) dataset using TensorFlow, the kernel died when run the model.fit(). Below is my code:

```auto
from transformers import AutoTokenizer
from transformers import TFAutoModelForSequenceClassification
from tensorflow.keras.optimizers import Adam
from datasets import load_dataset

dataset = load_dataset("glue", "cola")
dataset = dataset["train"]
tokenizer = AutoTokenizer.from_pretrained("bert-base-cased")

def tokenize_dataset(data):
    return tokenizer(data["sentence"])

dataset = dataset.map(tokenize_dataset)
model = TFAutoModelForSequenceClassification.from_pretrained("bert-base-cased")

tf_dataset = model.prepare_tf_dataset(dataset, batch_size=2, shuffle=True, tokenizer=tokenizer)
model.compile(optimizer=Adam(3e-5)) # No loss argument!

model.fit(tf_dataset)

```

I tried to reduce the batch size, didn’t resolve the issue.  
And the code works fine if I use the dataset as array instead of tf.dataset.

Does anyone have some thoughts on this?  
Thanks
