public void InitData(IDataset ds, int nhidden, Intarray newc2i = null, Intarray newi2c = null) { CHECK_ARG(nhidden > 1 && nhidden < 1000000, "nhidden > 1 && nhidden < 1000000"); int ninput = ds.nFeatures(); int noutput = ds.nClasses(); w1.Resize(nhidden, ninput); b1.Resize(nhidden); w2.Resize(noutput, nhidden); b2.Resize(noutput); Intarray indexes = new Intarray(); NarrayUtil.RPermutation(indexes, ds.nSamples()); Floatarray v = new Floatarray(); for (int i = 0; i < w1.Dim(0); i++) { int row = indexes[i]; ds.Input1d(v, row); float normv = (float)NarrayUtil.Norm2(v); v /= normv * normv; NarrayRowUtil.RowPut(w1, i, v); } ClassifierUtil.fill_random(b1, -1e-6f, 1e-6f); ClassifierUtil.fill_random(w2, -1.0f / nhidden, 1.0f / nhidden); ClassifierUtil.fill_random(b2, -1e-6f, 1e-6f); if (newc2i != null) { c2i.Copy(newc2i); } if (newi2c != null) { i2c.Copy(newi2c); } }