# Resuming/Loading Saved model

### Loading Model weights and optimizer

When you load pretrained weights for finetuning a network. Then after first iterations your loss actually increases than the pretrained network loss. It is because you didn't load the optimizer state, which may contains momentum of wights etc. And it takes few iterations to get the loss back to the pretrained converged loss value.&#x20;

Hence, if you want to finetune a model, you may want to load the optimizer as well. If you don't want to load the optimizer, then let the model train for first iterations untill it come back to it original converged loss and then you can do your own things. \
\
Note: If you only gonna use the pretrained model for evaluation and not gonna backprop though any loss, then you may not need to have optimizer state.&#x20;

### Batch norm Params

When you load the model, the running mean and variance are loaded for the batchnorm/dropout layers. Hence if you want to use it in eval mode, make sure to call `model.train().`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://theshank.gitbook.io/ai/pytorch/resuming-loading-saved-model.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
