# Generator has no attribute backward

**URL:** <https://discuss.huggingface.co/t/generator-has-no-attribute-backward/19407>\
**Category:** Beginners\
**Created:** [June 21, 2022, 1:21am UTC](https://discuss.huggingface.co/t/generator-has-no-attribute-backward/19407 "2022-06-21T01:21:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ablam](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ablam/32/4668_2.png) [@ablam](https://discuss.huggingface.co/u/ablam)\
**Post date:** [June 21, 2022, 1:21am UTC](https://discuss.huggingface.co/t/generator-has-no-attribute-backward/19407/1 "2022-06-21T01:21:03Z")

</div>

I’m finetuning InCoder-1B on a custom dataset with data that contains `[input_ids, attention_mask]` as columns. `[token_type_ids]` was not supported so I removed it.

In terms of training, I’m running 2 GPU’s on data-parallel and a gradient\_checkpoint to preserve memory, implemented on PyTorch. This is an issue in training I’m facing which I’m not sure how it came about or which of these aspects it could be related to.

 ![Screen Shot 2022-06-20 at 7.51.26 PM](https://us1.discourse-cdn.com/hellohellohello/original/2X/2/2591b8c1f1899700034f27d987db37cc1a5f783c.png)

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](https://discuss.huggingface.co/u/sgugger)\
**Post date:** [June 21, 2022, 1:33pm UTC](https://discuss.huggingface.co/t/generator-has-no-attribute-backward/19407/2 "2022-06-21T13:33:20Z")

</div>

From your message, it looks like your `batch` does not contain any label. Therefore your `outputs` probably don’t have a real `loss`.

---

<div class="post-metadata">

**Author:** ![ablam](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/ablam/32/4668_2.png) [@ablam](https://discuss.huggingface.co/u/ablam)\
**Post date:** [June 21, 2022, 2:03pm UTC](https://discuss.huggingface.co/t/generator-has-no-attribute-backward/19407/4 "2022-06-21T14:03:18Z")

</div>

That is correct! In the fine-tune with PyTorch tutorial it said to postproccess the `tokenized_dataset` as follows:

`tokenized_datasets = tokenized_datasets.rename_column("label", "labels")`

However, the only columns in my data are `['input_ids', 'attention_mask', "token_type_ids"]` (after removing `['text']`)

Thus, there is no corresponding labels column so I didn’t rename it.

But instead, I tried renaming `“token_type_ids”` to labels, i.e. `tokenized_datasets = tokenized_datasets.rename_column( "token_type_ids", "labels")` but incurred an error as well.

Any advice on how I should go about this?
