简体   繁体   中英

Is it possible to specify minimum and maximum weight values in encog?

I tried to specify the minimum and maximum weight constraints of a BasicNetwork, but I simply can't find a way to do it. Is it possible to set these constraints?

You could do something like this, the following code clamps the weights to between -10 and +10. You could place this right into the HelloWorldXOR example. The flat.getWeights is just a 1D array of the weights, so you can modify them as you wish.

    VectorAlgebra va = new VectorAlgebra();
    FlatNetwork flat = network.getFlat();
    do {
        train.iteration();
        va.clampComponents(flat.getWeights(), 5);
        System.out.println("Epoch #" + epoch + " Error:" + train.getError());
        epoch++;
    } while(train.getError() > 0.01);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM