Hi Petro,
I’m not sure if I understand your first question but I’ll give it a go.
If one doesn’t want to train from scratch every time, but rather use some saved state/weights they would have to load the weights from a file. In this code they load the model state into the weight_dicts variable. When you iterate over it, the k (key) represent the module/layer name and v (value) its corresponding weights. items() is a function you can call on dictionaries to get the keys and values.
By checking if the key from the loaded model exists in the existing model, we could filter the weights to only include the layers that match, and then later load the pre-trained model. Typically, you’d like to check so the keys match to avoid crashes caused by size differences in the fully connected layer at the very end of the network.