23 February 2011

Algortima Adaline

Program Jaringan Syaraf Tiruan ( Algoritma Adaline )


File Adaline.java

public class Adaline {
    private float[][] x;
    private float[] w;
    private float[] deltaW;
    private float[] t;
    //private float y;
    private float net;
    private float b;
    private float deltaWMax;    private int epoch;
    private int maxEpoch;
    private float alfa = 0.1f;
    private float maxError = 0.05f;

    public Adaline(){
        System.out.println("Metode Adaline");
        inisialisasi();
        training();

    }

    private void inisialisasi(){
        x = new float[4][2];
        x[0][0] = 1.0f;
        x[0][1] = 1.0f;
        x[1][0] = 1.0f;
        x[1][1] = -1.0f;
        x[2][0] = -1.0f;
        x[2][1] = 1.0f;
        x[3][0] = -1.0f;
        x[3][1] = -1.0f;

        t = new float[4];
        t[0] = 1.0f;
        t[1] = -1.0f;
        t[2] = -1.0f;
        t[3] = -1.0f;

        w = new float[2];
        deltaW = new float[2];
        for (int i=0;i<2;i++){
            w[i] = 0.0f;
            deltaW[i] = 0.0f;
        }

        b = 0.0f;
        //y = 0;
        deltaWMax = 0.0f;
        net = 0.0f;
        epoch = 0;
        maxEpoch = 10;
    }

    private int f(float net){
        if(net < 0)
            return -1;
        else
            return 1;
    }

    private void training(){
        do{
            epoch++;
            System.out.println("\nEpoch ke-"+epoch);
        System.out.println("Net          t-y       delta W1     delta W2      delta B      w1     w2     b");
            for(int i=0;i
                net = x[i][0] * w[0] + x[i][1] * w[1] + b;
                deltaW[0] = alfa * (t[i] - net) * x[i][0];
                w[0] = w[0] + deltaW[0];
                deltaW[1] = alfa * (t[i] - net) * x[i][1];
                w[1] = w[1] + deltaW[1];
                b = b + alfa * (t[i] - net);
                if (deltaW[0] > deltaW[1]) {
                    deltaWMax = deltaW[0];
                }else{
                    deltaWMax = deltaW[1];
                }
                System.out.println(net+"    "+(t[i]-net)+"    "+deltaW[0]+"     "+deltaW[1]+"     "+(alfa * (t[i] - net))+"     "+w[0]+"     "+w[1]+"     "+b+"      Max Delta W = "+deltaWMax);
            }
        }while(maxError < deltaWMax);
    }

    public int mapping(float x1, float x2){
        net = w[0] * x1 + w[1] * x2 + b;
        return f(net);    }}


Main.java

    public static void main(String[] args) {
        Adaline a = new Adaline();
        System.out.println("\n\nPengenalan pola AND");
        System.out.println("1 AND 1 hasilnya "+a.mapping(1, 1));
        System.out.println("1 AND -1 hasilnya "+a.mapping(1, -1));
        System.out.println("-1 AND 1 hasilnya "+a.mapping(-1, 1));
        System.out.println("-1 AND -1 hasilnya "+a.mapping(-1,-1));
    }
}



Artikel Terkait:

3 komentar:

Anonymous said...

average you should audition the status of casinos that engage fulfill video games are a
favourite focus among tourists. Warmer fill and velvet-textured smooth visual communication.
To tempt the huge assemble heavyweight gambling house is the point in time of the gambling hell causing
you vouchers for a lot of the session. online casinos no deposit bonus usa players contemptible you should call the damage of casinos that try fix television games are a favorite
dip among tourists. heater excretion and unnotched aerodynamic visual communication.
To lure the immense meet influential person cards is the kickoff of the cards causing you vouchers for a lot of the session.
My website: online casinos gratis bonus

toko sepatu online said...

for(int i=0;i
';' expected

ini msh ada kesalahanya pas dkompile ?
why?

toko sepatu online said...

for(int i=0;i
';' expected

ini msh ada kesalahanya pas dkompile ?
why?

Post a Comment

Tinggalkan Komentarmu Sob.

Sedikit Tentang Aye

Cari di Blog ini

Sobat Aye

Pesan Sobat

 
Copyright © Blognya Farhan