@Override public void setup(double deltaSmall, double deltaBig, double zygHeuristic, long seed, double canonThreshold) { this.seed = seed; rand = new XorShift1024StarRandom(seed); this.deltaSmall = deltaSmall; this.deltaBig = deltaBig; this.zygHeuristic = zygHeuristic; }
@Override public int nextInt() { return random.nextInt(); } });
@Override public double nextDouble() { return (nextLong() >>> 11) * 0x1.0p-53; }
if (random.nextDouble() > samplingRate) { continue;
@Override public void setSeed(long seed) { randomGenerator = new XorShift1024StarRandom(seed); }
@Override protected int next(final int bits) { return (int)(nextLong() >>> 64 - bits); }
@Override public void preProcess(MultiDataSet multiDataSet) { double alm = beta.nextDouble(); INDArray[] features = multiDataSet.getFeatures(); INDArray[] labels = multiDataSet.getLabels(); INDArray[] featureMasks = multiDataSet.getFeaturesMaskArrays(); INDArray[] labelMasks = multiDataSet.getLabelsMaskArrays(); int minibatchSize = features[0].size(0); INDArray[] tmpBuffer = new INDArray[minibatchSize]; int randomIndex1[] = new int[minibatchSize]; int randomIndex2[] = new int[minibatchSize]; // determine how this minibatch will be mixuped: for (int exampleIndex = 0; exampleIndex < minibatchSize; exampleIndex++) { tmpBuffer[exampleIndex] = null;// Nd4j.zeros(features[inputIndex].shape()); // draw two indices randomly from this minibatch, keep track of these indices // to mix labels and mask appropriately. randomIndex1[exampleIndex] = random.nextInt(minibatchSize); randomIndex2[exampleIndex] = random.nextInt(minibatchSize); // System.out.printf("exampleIndex %d randomIndex1: %d randomIndex2: %d %n",exampleIndex, randomIndex1[exampleIndex], randomIndex2[exampleIndex]); } for (INDArray feature : features) shuffle(minibatchSize, alm, feature, randomIndex1, randomIndex2); for (INDArray label : labels) shuffle(minibatchSize, alm, label, randomIndex1, randomIndex2); if (featureMasks != null) for (INDArray featureMask : featureMasks) keepLongestMask(minibatchSize, featureMask, randomIndex1, randomIndex2); if (labelMasks != null) for (INDArray labelMask : labelMasks) keepLongestMask(minibatchSize, labelMask, randomIndex1, randomIndex2); }
@Override public void setSeed(long seed) { rand = new XorShift1024StarRandom(seed); }
@Override public float nextFloat() { return (nextLong() >>> 40) * 0x1.0p-24f; }
@Override public void setSeed(long seed) { randomGenerator = new XorShift1024StarRandom(seed); }
@Override public boolean nextBoolean() { return nextLong() < 0; }
@Override public void setSeed(long seed) { randomGenerator = new XorShift1024StarRandom(seed); firstSimulationStrategy.setSeed(seed); }
@Override public int nextInt() { return (int)nextLong(); }
public MixupMultiDataSetPreProcessor(long seed, double alpha) { random = new XorShift1024StarRandom(seed); assert alpha > 0 : "alpha must be strictly positive."; beta = new Beta(alpha, alpha, new RandomEngine() { @Override public int nextInt() { return random.nextInt(); } }); this.alpha = alpha; }
@Override public int nextInt(final int n) { return (int)nextLong(n); }
@Override public void setSeed(long seed) { randomGenerator = new XorShift1024StarRandom(seed); firstSimulationStrategy.setSeed(seed); }
/** The jump function for this generator. It is equivalent to 2<sup>512</sup> * calls to {@link #nextLong()}; it can be used to generate 2<sup>512</sup> * non-overlapping subsequences for parallel computations. */ public void jump() { final long[] t = new long[16]; for (int i = 0; i < JUMP.length; i++) for (int b = 0; b < 64; b++) { if ((JUMP[i] & 1L << b) != 0) for (int j = 0; j < 16; j++) t[j] ^= s[(j + p) & 15]; nextLong(); } for (int j = 0; j < 16; j++) s[(j + p) & 15] = t[j]; }
/** * Returns a new instance that shares no mutable state * with this instance. The sequence generated by the new instance * depends deterministically from the state of this instance, * but the probability that the sequence generated by this * instance and by the new instance overlap is negligible. * * @return the new instance. */ public XorShift1024StarRandom split() { final XorShift1024StarRandom split = new XorShift1024StarRandom(); for(int i = s.length; i-- != 0;) split.s[i] = HashCommon.murmurHash3(s[i]); split.p = p; return split; }
@Override public void nextBytes(final byte[] bytes) { int i = bytes.length, n = 0; while(i != 0) { n = Math.min(i, 8); for (long bits = nextLong(); n-- != 0; bits >>= 8) bytes[--i] = (byte)bits; } }
RecordReader reader = new RecordReader(inPath); RecordWriter writer = new RecordWriter(outPath); Random rand = new XorShift1024StarRandom();