Definition at line 26 of file Randomize.cpp.
◆ run()
Implements nnkit::Action.
Definition at line 28 of file Randomize.cpp.
29 {
30 int seed = std::chrono::system_clock::now().time_since_epoch().count();
31
32 std::minstd_rand rand(seed);
33 std::normal_distribution<float> dist(0.0f, 2.0f);
34
35 for (uint32_t n = 0; n < ctx.
size(); ++n)
36 {
38
39 auto fn = [&dist, &rand](
const TensorContext &ctx, uint32_t n, Accessor<float> &t) {
42
43 for (IndexEnumerator e{ctx.shape(n)}; e.valid(); e.advance())
44 {
45 t.at(e.current()) = dist(rand);
46 }
47 };
48
49 ctx.getMutableFloatTensor(n, fn);
50 }
51 }
virtual uint32_t size(void) const =0
References nnkit::TensorContext::size().
The documentation for this struct was generated from the following file: