I am trying to study the effect of random seeds on the dropout and linear initialization of the model. Here is a snippet of my model
class PoolerClassifier(nn.Module):
def __init__(self, transformer: nn.Module, transformer_dropout: float, linear_dropout: float,
input_size: int, num_classes: int, seed: int):
super(PoolerClassifier, self).__init__()
self.transformer = transformer(transformer_dropout) # Transformer dropout here
self.linear_dropout = nn.Dropout(p=linear_dropout) # Linear dropout here
self.linear = nn.Linear(input_size, num_classes) # Linear initialization here
def forward(self, inputs):
transformer_outputs = self.transformer(**inputs)
vectors = self.linear_dropout(transformer_outputs.pooler_output)
logits = self.linear(vectors)
return logits
I have three questions:
The first one is: Ideally I would like to assign different random seeds to:
- transformer dropout: random_seed(1)
- linear dropout: random_seed(2)
- linear initialization: random_seed(3)
My second question is: How can I selectively apply random seed to any of them. To elaborate, I would like to do the following:
- transformer dropout - Set random seed - So deterministic behaviour
- linear dropout - No random seed - So random behaviour
- linear initialization - Set random seed - So deterministic behaviour
- Very importantly: Remove random seed so everything else following the model has non-deterministic behaviour
My third question is: Can I do something like this: nn.Dropout(random_state=12345)
?
Thank you very much for your help.