Senin, 04 Januari 2010

Algoritma Delta rule dengan fungsi OR dan XOR

class pertama

public abstract class All
{javascript:void(0)
abstract public void learn(double[][] inputan,double[] target);
abstract public void test(double in1, double in2);
abstract public void fresh();

double inputan[][]=new double[4][2];
public double target[]=new double[4];
double bobot[]={0,0};
double bias;
double y=0;
double yOut=0;
public boolean kondisi;
}


class kedua
class DeltaRule extends All
{
final double alfa=0.2;
final double teta=0.5;
double output[]=ne w double[target.length];
double eror[]=new double[inputan.length];
boolean kondisi;
double bobot[]={0.1,0.3};
int epoh;

public void learn(double[][] inputan,double[] target)
{
kondisi=false;
epoh=0;
do
{
System.out.println(++epoh);
for(int a=0; a "+(int)targ[0]+"\n"+
(int)input[1][0]+" "+(int)input[1][1]+" -> "+(int)targ[1]+"\n"+
(int)input[2][0]+" "+(int)input[2][1]+" -> "+(int)targ[2]+"\n"+
(int)input[3][0]+" "+(int)input[3][1]+" -> "+(int)targ[3]+"\n");
}

void aksi()
{
start.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
inputan();
target();
cetak();

if(cbMode.getSelectedItem().toString()==mod[1])
{
Pmode=cbMode.getSelectedItem().toString();
d.fresh();
d.learn(inputan(),target());
if(d.epoh<20000)
teks.append("\n"+"Jumlah Epoh : "+d.epoh);
else
{
teks.append("\n"+"Gak Ngerti..!");
JOptionPane.showMessageDialog(null,"Sory.. Sistem Gak Ngerti","Konfirmasi",
JOptionPane.ERROR_MESSAGE);
}
}

else
{
System.out.println("Pilih mode dulu dong");
JOptionPane.showMessageDialog(null,"Sory.. Pilih Mode Pembelajaran Dulu!","Ingat",
JOptionPane.ERROR_MESSAGE);
}
}
});

tes.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{

if(Pmode==mod[1])
{
d.test(Double.parseDouble(tes1.getSelectedItem().toString()),
Double.parseDouble(tes2.getSelectedItem().toString()));
teks2.setText("Input 1 : "+Integer.parseInt(tes1.getSelectedItem().toString())+
"\n"+"Input 2 : "+Integer.parseInt(tes2.getSelectedItem().toString())+
"\n"+"Maka Outputnya : "+(int)d.y);
}

else
{
System.out.println("Dites dulu dong");
JOptionPane.showMessageDialog(null,"Sory.. Silakan Beri Pembelajaran Terlebih dahulu!",
"Eror",JOptionPane.ERROR_MESSAGE);
}
}
});
}

}




Untuk eksekusi programnya: