代码拉取完成,页面将自动刷新
class torch.nn.Dropout(
p=0.5,
inplace=False
)
For more information, seetorch.nn.Dropout.
class mindspore.nn.Dropout(
keep_prob=0.5,
dtype=mstype.float
)
For more information, seemindspore.nn.Dropout.
PyTorch:p - Probability of an element to be zeroed. Default: 0.5.
PyTorch: The parameter P is the probability of discarding the parameter.
MindSpore:keep_prob (float) - The keep rate, greater than 0 and less equal than 1. E.g. rate=0.9, dropping out 10% of input units. Default: 0.5.
MindSpore:The parameter keep_prob is the probability of carding the parameter.
# The following implements Dropout with MindSpore.
import torch.nn
import mindspore.nn
import numpy as np
m = torch.nn.Dropout(p=0.9)
input = torch.tensor(np.ones([5,5]),dtype=float)
output = m(input)
print(output)
# out:
# [[0 10 0 0 0]
# [0 0 0 0 0]
# [0 0 10 0 0]
# [0 10 0 0 0]
# [0 0 0 0 10]]
input = mindspore.Tensor(np.ones([5,5]),mindspore.float32)
net = mindspore.nn.Dropout(keep_prob=0.1)
net.set_train()
output = net(input)
print(output)
# out:
# [[0 10 0 0 0]
# [0 0 0 10 0]
# [0 0 0 0 0]
# [0 10 10 0 0]
# [0 0 10 0 0]]
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。