def dropout_layer(x,dropout):
assert 0 <= dropout<=1
if dropout==1:
return torch.zeros_like(x)
if dropout==0:
return x
mask=(torch.randn(x.shape)>dropout).float()
return mask*x /(1.0-dropout)
dropout代码实现原理
最新推荐文章于 2026-03-02 00:07:06 发布

308

被折叠的 条评论
为什么被折叠?



