How to utilize Hebbian learning?

前端 未结 4 1595
天涯浪人
天涯浪人 2021-01-30 17:43

I want to upgrade my evolution simulator to use Hebb learning, like this one. I basically want small creatures to be able to learn how to find food. I achieved that with the bas

4条回答
  •  無奈伤痛
    2021-01-30 18:40

    You can try with my code.

    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package modelhebb;
    
    /**
     *
     * @author Raka
     */
    public class ModelHebb {
        public static void main(String[] args) {
            Integer xinput[][]  = new Integer[][]{
                {1, 1},
                {1, -1},
                {-1, 1},
                {-1, -1}
            };
            Integer xtarget[]   = new Integer[]{
                1,
                -1,
                -1,
                -1
            };
            Integer xweight[]   = new Integer[xinput[0].length];
            System.out.println("\t Iterasi \t");
            Integer bayes   = 0;
            for (int i = 0; i < xtarget.length; i++) {
                for (int j = 0; j < xinput[i].length; j++) {
                    int temp    = xweight[j]==null?0:xweight[j];
                    xweight[j]  = temp + (xinput[i][j] * xtarget[i]);
                    System.out.print("W"+j+": "+xweight[j]+"\t");
                }
                bayes   = bayes + xtarget[i];
                System.out.println("Bobot : " + bayes);
            }
        }
    }

提交回复
热议问题