# Resume in train\_unconditional.py

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fresume-in-train-unconditional-py%2F25876%3E%5C
**Category:** 🧨 Diffusers\
**Created:** [November 10, 2022, 3:52pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fresume-in-train-unconditional-py%2F25876 "2022-11-10T15:52:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbmaxwell](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jbmaxwell](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjbmaxwell)%5C
**Post date:** [November 10, 2022, 3:52pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fresume-in-train-unconditional-py%2F25876%2F1 "2022-11-10T15:52:37Z")

</div>

I’m just running some initial tests/experiments in `train_unconditional.py`, to get a sense of how my data/images are going to work with Diffusers and I’d like to continue training from a saved checkpoint. I modified the script to use:

```auto
if args.overwrite_output_dir:
        model = UNet2DModel(
            // original model code
        )
    else:
        model_dir = args.output_dir + '/unet/'
        model = UNet2DModel.from_pretrained(model_dir)

```

which does appear to successfully load my checkpoint (based on the initial loss). However, when I run it, I see that the loss is clearly diverging. I’m guessing I don’t have the correct scheduler/optimizer settings, but I’m not sure how to load those.

Any tips appreciated.

---

<div class="post-metadata">

**Author:** ![pcuenq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pcuenq/32/32135_2.png) [@pcuenq](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fpcuenq)%5C
**Post date:** [November 11, 2022, 8:48am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fresume-in-train-unconditional-py%2F25876%2F2 "2022-11-11T08:48:56Z")

</div>

Hi @jbmaxwell! I think that’s an interesting use case, would you mind [opening an issue in the repo](https://github.com/huggingface/diffusers/issues)?

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![jbmaxwell](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jbmaxwell](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjbmaxwell)%5C
**Post date:** [November 11, 2022, 4:05pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fresume-in-train-unconditional-py%2F25876%2F3 "2022-11-11T16:05:28Z")

</div>

Okay, will do.

---

<div class="post-metadata">

**Author:** ![pcuenq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pcuenq/32/32135_2.png) [@pcuenq](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fpcuenq)%5C
**Post date:** [November 11, 2022, 4:06pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fresume-in-train-unconditional-py%2F25876%2F4 "2022-11-11T16:06:55Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![jbmaxwell](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jbmaxwell](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjbmaxwell)%5C
**Post date:** [November 11, 2022, 11:59pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fresume-in-train-unconditional-py%2F25876%2F5 "2022-11-11T23:59:57Z")

</div>

Actually, it looks like the problem is really just that the learning rate doesn’t continue from where it was at the end of the last run—i.e., it just runs the whole lr schedule again, as if training from scratch. So it starts okay, diverges for a while, then starts to converge again.  
Probably it’s something I’ve missed… ??
