public override void Forward(Variable x) { Input = x; var p = 1 - Rate; noise = TVar.RandomBernoulli(new SeedSource(), p, Global.Device, x.Data.ElementType, x.Data.Shape) .Div(p) .Evaluate(); Output = Output.TVar().CMul(noise).Evaluate(); }
public override Tensor Forward(Tensor input, ModelMode mode) { Ops.Copy(activation, input); if (mode == ModelMode.Train) { var p = 1 - pRemove; TVar.RandomBernoulli(seedSource, p, allocator, elementType, noise.Sizes) .Div(p) .Evaluate(noise); activation.TVar() .CMul(noise) .Evaluate(activation); } return(activation); }