To fine-tune a pretrained model for a new task you usually keep the backbone and replace the head: an ImageNet classifier has a 1000-way output layer, but your dataset has 10 classes. Loading the pretrained checkpoint straight into the new model would crash on the mismatched head. The standard recipe copies every pretrained tensor whose name and shape both match the new model, leaves the others at their fresh initialization, and reports what was copied and what was skipped. The report is not decoration: silently skipping a backbone layer because of a naming change is a common bug that makes "pretrained" training behave like training from scratch.
Implement transfer_weights.
src and dst are dicts mapping parameter names to NumPy arrays (like state dicts). Return (new_dst, copied, skipped).dst: if the name is in src and the shapes are equal, new_dst[name] is a copy of src[name] and the name is in copied; otherwise new_dst[name] is a copy of dst[name] and the name is in skipped.copied and skipped are alphabetically sorted lists. Names present only in src are ignored. Neither input dict nor array is modified, and the returned arrays are copies.np.array(x, copy=True) makes an independent copy.
A matching name with a different shape (a resized head) goes to skipped.
No results yet
Run your code to check it against the examples, or submit to run every test.