23template<
typename AFloat>
27 AFloat dropoutProbability)
29 AFloat *
data = A.GetData();
32 size_t seed = dlRand.
Integer(4294967295);
34 size_t nElements = A.GetSize();
39 auto f = [&
data, dropoutProbability, &nSteps, &nElements, &seed](
UInt_t workerID)
42 size_t iMax = std::min(workerID+nSteps,nElements);
43 for (
size_t i = workerID; i < iMax; ++i) {
44 AFloat
r = rand.Uniform();
45 data[i] = (
r > dropoutProbability) ? 0.0 :
data[i] / dropoutProbability;
53 for (
size_t i = 0; i < nElements; i+=nSteps)
60template<
typename AFloat>
61void TCpu<AFloat>::Dropout(TCpuMatrix<AFloat> &A,
62 AFloat dropoutProbability)
64 AFloat *
data = A.GetRawDataPointer();
66 auto f = [&
data, dropoutProbability](
UInt_t workerID)
68 TRandom rand(time(
nullptr) + workerID);
69 AFloat
r = rand.Uniform();
70 data[workerID] = (
r > dropoutProbability) ? 0.0 :
data[workerID] / dropoutProbability;
74 A.GetThreadExecutor().Map(
f,
ROOT::TSeqI(A.GetNoElements()));
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
A pseudo container class which is a generator of indices.
static size_t GetNWorkItems(size_t nelements)
static Executor & GetThreadExecutor()
static TRandom & GetRandomGenerator()
static void DropoutForward(Tensor_t &A, TDescriptors *descriptors, TWorkspace *workspace, Scalar_t p)
Apply dropout with activation probability p to the given tensor A and scale the result by reciprocal ...
void Foreach(Function func, unsigned int nTimes, unsigned nChunks=0)
wrap TExecutor::Foreach
This is the base class for the ROOT Random number generators.
virtual UInt_t Integer(UInt_t imax)
Returns a random integer uniformly distributed on the interval [ 0, imax-1 ].
create variable transformations