Hey guys,
can anyone of you could explain why such things below happened?
 def __init__(self, config):
        super(BertForMultitask, self).__init__(config)
        self.bert = BertModel(config)
        self.dropout = nn.Dropout(config.hidden_dropout_prob)
        self.apply(self.init_weights)
        self.multitask_ratio = self.set_update_ratio(config, 0.7)

        #####################
        ####    Part A. This works     ####
        #####################
        self.classifier_student = nn.Linear(config.hidden_size, 2)
        self.classifier_squad = nn.Linear(config.hidden_size, 2)
        self.classifier_usermatch = nn.Linear(config.hidden_size, 2)
        self.classifier_stsb = nn.Linear(config.hidden_size, 1)

        ########################
        ####    Part B. Below doesn't     ####
        ########################        
        self.classifier = {}
        for task in config.tasks:
             if task in ['student_response', 'squad', 'user_match']:
                 self.classifier[task] = nn.Linear(config.hidden_size, self.config.num_labels)
             elif task in ['sts-b']:
                 self.classifier[task] = nn.Linear(config.hidden_size, 1)

I’ve been implementing multitask model that deals with several different tasks
and I’ve trained with each of different Linear layer for each task after the inputs
pass through a BERT model.
However, the problem here is that when I defined the Linear layers for each task
just like the part B - dictionary holding each linear layers for each tasks - then it seems
the model doesn’t hold the trained parameters of that layer after it completes the training.
Part A where each layer is defined separately, not aggregated in a single python dictionary,
works just fine.
Is there any secret behind this means of defining layers?
Anyone knows any clue?