Hello everybody,
Im a very new PyTorch user, and I have a question which might be trivial but maybe not. Im trying to implement my own model for fusing multiple modalities, e.g. RGB and optical flow. What I want to do is to use a well known model (e.g. VGG) as my base model, to create a two-stream network. As I was reading in the PyTorch documentation I could do something like:
    class Model(nn.Module):
        def __init__(self):
            super(Model, self).__init__()
            self.rgb = torchvision.models.vgg16(True)
            self.optical_flow = torchvision.models.vgg16(True)

where later on, I will first modify the optical flow net in the first conv layer to take as input channels consecutive optical flow images, I will remove the last two fully connected layers, I will concatenate the features of the first fully connected layer of the two nets and add on top two new fully connected layers.
My problem is that I will not use only optical flows and RGBs but other modalities as well (each time I will use a combination of 2), where the user will be able to choose which modalities to use. So I was thinking to do something like
    class Model(nn.Module):
        def __init__(self, modalities):
            #modalities argument is a list of strings which indicates which modalities to be fused
            super(Model, self).__init__()
            self.base_models = {}
            for m in modalities:
                 self.base_model[m] = torchvision.models.vgg16(True)

and later on modify each network accordingly. Is something like this possible to be done, i.e. to use a dictionary which will contain different models as submodules of the whole module? Im asking this because the documentation indicates to assign submodules to regular attributes and not to dictionaries. If this is not possible is there an alternative that you can suggest?
I hope I explained well the situation. Thank you in advance.