trained_model=torchvision.models.resnet18(pretrained=True)
model=nn.Sequential(*list(trained_model.children())[:-1],
nn.Flatten(),
nn.Linear(512, 5)
)
I guess I understand how the transfered learning work here:
in the new model
:
*list(trained_model.children())[:-1]
must be (I guess) working as a fixed function without introducing any new parameters. So when you train model
, you will only update the parameters introduced by nn.Linear(512, 5)
.
In this way, the transfered learning is done, am I right?
What I don’t understand is this *
, what it does?
I can understand I used the first 17 children layers of the trained _model
by using list(trained_model.children())[:-1]
, but isn’t this already enough? why add a *
here?
Thanks.