diff --git a/d2l/mindspore.py b/d2l/mindspore.py index 7b9523b..4515573 100644 --- a/d2l/mindspore.py +++ b/d2l/mindspore.py @@ -1291,7 +1291,7 @@ def __init__(self, key_size, query_size, num_hiddens, dropout, **kwargs): self.W_k = nn.Dense(key_size, num_hiddens, has_bias=False) self.W_q = nn.Dense(query_size, num_hiddens, has_bias=False) self.w_v = nn.Dense(num_hiddens, 1, has_bias=False) - self.dropout = nn.Dropout(1 - dropout) + self.dropout = nn.Dropout(p = dropout) def construct(self, queries, keys, values, valid_lens): queries, keys = self.W_q(queries), self.W_k(keys) @@ -1307,7 +1307,7 @@ class DotProductAttention(nn.Cell): def __init__(self, dropout, **kwargs): super(DotProductAttention, self).__init__(**kwargs) - self.dropout = nn.Dropout(1 - dropout) + self.dropout = nn.Dropout(p = dropout) def construct(self, queries, keys, values, valid_lens=None): d = queries.shape[-1] @@ -1376,7 +1376,7 @@ class PositionalEncoding(nn.Cell): def __init__(self, num_hiddens, dropout, max_len=1000): super(PositionalEncoding, self).__init__() - self.dropout = nn.Dropout(1 - dropout) + self.dropout = nn.Dropout(p = dropout) self.P = d2l.zeros((1, max_len, num_hiddens)) X = d2l.arange(max_len, dtype=mindspore.float32).reshape( -1, 1) / d2l.pow(10000, d2l.arange( @@ -1408,7 +1408,7 @@ class AddNorm(nn.Cell): def __init__(self, normalized_shape, dropout, **kwargs): super(AddNorm, self).__init__(**kwargs) - self.dropout = nn.Dropout(1 - dropout) + self.dropout = nn.Dropout(p = dropout) self.ln = d2l.LayerNorm(normalized_shape) def construct(self, X, Y):