Programming, Artificial Intelligence, Machine Learning, Data Science, Python.
nn.Dropout(dropout) def forward(self, x, mask=None): attention_output, _ = self.self_attention(x, x, x, attn_mask=mask) x = x + self.dropout(attention_output) x = self.norm1(x) feedforward_output = self.feedforward(x) x = x + self.dropout(feedforward_output) x = self.norm2(x) return x class