Search in sources :

Example 11 with XorShift128PlusRandom

use of jcog.math.random.XorShift128PlusRandom in project narchy by automenta.

the class HijackBagTest method testHijackSampling.

@Test
public void testHijackSampling() {
    for (int cap : new int[] { 63, 37 }) {
        int rep = 3;
        int batch = 4;
        int extraSpace = 5;
        final Random rng = new XorShift128PlusRandom(1);
        DefaultHijackBag bag = new DefaultHijackBag(plus, cap * extraSpace, rep) {

            @Override
            public void onRemove(Object value) {
                fail("");
            }

            @Override
            public void onReject(Object value) {
                fail("");
            }
        };
        fillLinear(bag, cap);
        testBagSamplingDistribution(bag, batch);
        bag.print();
    }
}
Also used : XorShift128PlusRandom(jcog.math.random.XorShift128PlusRandom) Random(java.util.Random) XorShift128PlusRandom(jcog.math.random.XorShift128PlusRandom) DefaultHijackBag(jcog.bag.impl.hijack.DefaultHijackBag) Test(org.junit.jupiter.api.Test) BagTest(jcog.bag.BagTest)

Example 12 with XorShift128PlusRandom

use of jcog.math.random.XorShift128PlusRandom in project narchy by automenta.

the class LSTMView method main.

public static void main(String[] arg) {
    Random r = new XorShift128PlusRandom(1234);
    DistractedSequenceRecall task = new DistractedSequenceRecall(r, 32, 8, 8, 100);
    int cell_blocks = 16;
    SimpleLSTM lstm = task.lstm(cell_blocks);
    float lr = 0.1f;
    // initialize
    task.scoreSupervised(lstm, lr);
    SpaceGraph.window(new LSTMView(lstm), 800, 800);
    int epochs = 5000;
    for (int epoch = 0; epoch < epochs; epoch++) {
        double fit = task.scoreSupervised(lstm, lr);
        if (epoch % 10 == 0)
            System.out.println("[" + epoch + "] error = " + (1 - fit));
        Util.sleep(1);
    }
    System.out.println("done.");
}
Also used : XorShift128PlusRandom(jcog.math.random.XorShift128PlusRandom) Random(java.util.Random) XorShift128PlusRandom(jcog.math.random.XorShift128PlusRandom) SimpleLSTM(jcog.learn.lstm.SimpleLSTM) DistractedSequenceRecall(jcog.learn.lstm.DistractedSequenceRecall)

Aggregations

XorShift128PlusRandom (jcog.math.random.XorShift128PlusRandom)12 Random (java.util.Random)6 Test (org.junit.jupiter.api.Test)6 Unify (nars.term.subst.Unify)3 Frequency (org.apache.commons.math3.stat.Frequency)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 DistractedSequenceRecall (jcog.learn.lstm.DistractedSequenceRecall)2 SimpleLSTM (jcog.learn.lstm.SimpleLSTM)2 Compound (nars.term.Compound)2 Joiner (com.google.common.base.Joiner)1 BagTest (jcog.bag.BagTest)1 DefaultHijackBag (jcog.bag.impl.hijack.DefaultHijackBag)1 PriReference (jcog.pri.PriReference)1 PatternIndex (nars.index.term.PatternIndex)1 Term (nars.term.Term)1 Assertions (org.junit.jupiter.api.Assertions)1