seniorPyTorch

What is the difference between state_dict and model.parameters() in PyTorch?

Updated May 17, 2026

Short answer

state_dict stores named tensors of model weights, while parameters() returns iterable parameter objects for optimization.

Deep explanation

state_dict is a Python dictionary mapping parameter/buffer names to tensors, making it ideal for saving/loading models. parameters() returns raw parameter tensors used by optimizers. Buffers like running_mean in BatchNorm are included in state_dict but not parameters().

Unlock with a Pro subscription to view this section.

View pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More PyTorch interview questions

View all →