hassony2/kinetics_i3d_pytorch

Transfer Learning

Closed this issue · 3 comments

How can I change the Module to adapt it to the UCF101 dataset? If I changed the model (ie changed the out number of classes) , the pretrain weight is still work?

Hi @vateye ,

Here is how I do it:

  • I first initialize the network with the pretrained weights
i3dnet = i3d.I3D(class_nb=400, modality='flow', dropout_rate=0.5)
  • then I change the classification layer
i3dnet.conv3d_0c_1x1 = Unit3Dpy(
            in_channels=1024,
            out_channels=self.class_nb,
            kernel_size=(1, 1, 1),
            activation=None,
            use_bias=True,
            use_bn=False)

This way only the layer of the classifier does not have pretrained weights.

Hope this answers your question :)

Thanks your help!
I have another question, if I wanna extent the model,should I load the pre-trained weight before I extent other module on the last conv3d layer?

Yes, you would first load the weights. Any additional module added after that will have its weights initialized independently of the pre-trained weights.
Hope this helps :)