Berikut Source Code nya
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
Berikut Source Code nya
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace Jst_Hebbrule
- {
- public partial class Form1 : Form
- {
- int[] X1 = new int[4];
- int[] X2 = new int[4];
- int[] Target = new int[4];
- int sign;
- int[] W1 = new int[4];
- int[] W2 = new int[4];
- int w_old;
- int[] bias = new int[4];
- int bias_lama;
- int[] output = new int[4];
- int jenis_bilangan;
- public Form1()
- {
- InitializeComponent();
- }
- private void button5_Click(object sender, EventArgs e)
- {
- jenis_bilangan = 1;
- X1[0] = 0; X2[0] = 0;
- X1[1] = 0; X2[1] = 1;
- X1[2] = 1; X2[2] = 0;
- X1[3] = 1; X2[3] = 1;
- Btn.Enabled = false;
- button7.Enabled = false;
- Txtx11.Text = Convert.ToString(X1[0]); ; Txtx21.Text = Convert.ToString(X2[0]);
- Txtx12.Text = Convert.ToString(X1[1]); ; Txtx22.Text = Convert.ToString(X2[1]);
- Txtx13.Text = Convert.ToString(X1[2]); ; Txtx23.Text = Convert.ToString(X2[2]);
- Txtx14.Text = Convert.ToString(X1[3]); ; Txtx24.Text = Convert.ToString(X2[3]);
- TxtT1.Text = ""; TxtW11.Text = "";
- TxtT2.Text = ""; TxtW12.Text = "";
- TxtT3.Text = ""; TxtW13.Text = "";
- TxtT4.Text = ""; TxtW14.Text = "";
- Txtb1.Text = ""; TxtW21.Text = "";
- Txtb2.Text = ""; TxtW22.Text = "";
- Txtb3.Text = ""; TxtW23.Text = "";
- Txtb4.Text = ""; TxtW24.Text = "";
- TxtO1.Text = "";
- TxtO2.Text = "";
- TxtO3.Text = "";
- TxtO4.Text = "";
- }
- private void button6_Click(object sender, EventArgs e)
- {
- jenis_bilangan = 0;
- X1[0] = -1; X2[0] = -1;
- X1[1] = -1; X2[1] = 1;
- X1[2] = 1; X2[2] = -1;
- X1[3] = 1; X2[3] = 1;
- Btn.Enabled = false;
- button7.Enabled = false;
- Txtx11.Text = Convert.ToString(X1[0]); ; Txtx21.Text = Convert.ToString(X2[0]);
- Txtx12.Text = Convert.ToString(X1[1]); ; Txtx22.Text = Convert.ToString(X2[1]);
- Txtx13.Text = Convert.ToString(X1[2]); ; Txtx23.Text = Convert.ToString(X2[2]);
- Txtx14.Text = Convert.ToString(X1[3]); ; Txtx24.Text = Convert.ToString(X2[3]);
- TxtT1.Text = ""; TxtW11.Text = "";
- TxtT2.Text = ""; TxtW12.Text = "";
- TxtT3.Text = ""; TxtW13.Text = "";
- TxtT4.Text = ""; TxtW14.Text = "";
- Txtb1.Text = ""; TxtW21.Text = "";
- Txtb2.Text = ""; TxtW22.Text = "";
- Txtb3.Text = ""; TxtW23.Text = "";
- Txtb4.Text = ""; TxtW24.Text = "";
- TxtO1.Text = "";
- TxtO2.Text = "";
- TxtO3.Text = "";
- TxtO4.Text = "";
- }
- private void button1_Click(object sender, EventArgs e)
- {
- int i;
- Btn.Enabled = true ;
- //button7.Enabled = true;
- for (i = 0; i <=3; i++)
- {
- if (X1[i] == -1)
- {
- X1[i] = 0;
- sign = 1;
- if (X2[i] == -1)
- {
- X2[i] = 0;
- Target[i] = X1[i] & X2[i];
- X1[i] = -1;
- X2[i] = -1;
- if (Target[i] == 0)
- { Target[i] = -1; }
- else
- {
- Target[i] = 1;
- }
- }
- else
- {
- Target[i] = X1[i] & X2[i];
- X1[i] = -1;
- if (Target[i] == 0)
- { Target[i] = -1; }
- else
- {
- Target[i] = 1;
- }
- }
- }
- else if (X2[i] == -1)
- {
- X2[i] = 0;
- sign = 1;
- Target[i] = Target[i] = X1[i] & X2[i];
- X2[i] = -1;
- if (Target[i] == 0)
- { Target[i] = -1; }
- else
- {
- Target[i] = 1;
- }
- }
- else
- {
- Target[i] = X1[i] & X2[i];
- }
- }
- TxtT1.Text = Convert.ToString(Target[0]);
- TxtT2.Text = Convert.ToString(Target[1]);
- TxtT3.Text = Convert.ToString(Target[2]);
- TxtT4.Text = Convert.ToString(Target[3]);
- }
- private void button2_Click(object sender, EventArgs e)
- {
- int i;
- Btn.Enabled = true;
- //button7.Enabled = true;
- for (i = 0; i <= 3; i++)
- {
- if (X1[i] == -1)
- {
- X1[i] = 0;
- sign = 1;
- if (X2[i] == -1)
- {
- X2[i] = 0;
- Target[i] = X1[i] | X2[i];
- X2[i] = -1;
- X1[i] = -1;
- if (Target[i] == 0)
- { Target[i] = -1; }
- else
- {
- Target[i] = 1;
- }
- }
- else
- {
- Target[i] = X1[i] | X2[i];
- X1[i] = -1;
- if (Target[i] == 0)
- { Target[i] = -1; }
- else
- {
- Target[i] = 1;
- }
- }
- }
- else if (X2[i] == -1)
- {
- X2[i] = 0;
- sign = 1;
- Target[i] = Target[i] = X1[i] | X2[i];
- X2[i] = -1;
- if (Target[i] == 0)
- { Target[i] = -1; }
- else
- {
- Target[i] = 1;
- }
- }
- else
- {
- Target[i] = X1[i] | X2[i];
- }
- }
- TxtT1.Text = Convert.ToString(Target[0]);
- TxtT2.Text = Convert.ToString(Target[1]);
- TxtT3.Text = Convert.ToString(Target[2]);
- TxtT4.Text = Convert.ToString(Target[3]);
- }
- private void button3_Click(object sender, EventArgs e)
- {
- int i;
- Btn.Enabled = true;
- //button7.Enabled = true;
- for (i = 0; i <= 3; i++)
- {
- if (X1[i] == -1)
- {
- sign= 1;
- X1[i] = 0;
- if (X2[i] == -1)
- {
- X2[i] = 0;
- Target[i] = X1[i] ^ X2[i];
- X2[i] = -1;
- X1[i] = -1;
- if (Target[i] == 0)
- { Target[i] = -1; }
- else
- {
- Target[i] = 1;
- }
- }
- else
- {
- Target[i] = X1[i] ^ X2[i];
- X1[i] = -1;
- if (Target[i] == 0)
- { Target[i] = -1; }
- else
- {
- Target[i] = 1;
- }
- }
- }
- else if (X2[i] == -1)
- {
- X2[i] = 0;
- sign = 1;
- Target[i] = Target[i] = X1[i] ^ X2[i];
- X2[i] = -1;
- if (Target[i] == 0)
- { Target[i] = -1; }
- else
- {
- Target[i] = 1;
- }
- }
- else
- {
- if ( sign == 1)
- {
- Target[i] = X1[i] ^ X2[i];
- if (Target[i] == 0)
- { Target[i] = -1; }
- else
- {
- Target[i] = 1;
- }
- }
- else
- {
- Target[i] = X1[i] ^ X2[i];
- }
- }
- }
- TxtT1.Text = Convert.ToString(Target[0]);
- TxtT2.Text = Convert.ToString(Target[1]);
- TxtT3.Text = Convert.ToString(Target[2]);
- TxtT4.Text = Convert.ToString(Target[3]);
- }
- private void Btn_Click(object sender, EventArgs e)
- {
- int i;
- w_old = 0;
- bias_lama = 0;
- //Btn.Enabled = true;
- button7.Enabled = true;
- for (i = 0; i <= 3; i++)
- {
- W1[i] = w_old + (X1[i] * Target[i]);
- w_old = W1[i];
- bias[i] = bias_lama + Target[i];
- bias_lama = bias[i];
- }
- w_old = 0;
- for (i = 0; i <= 3; i++)
- {
- W2[i] = w_old + (X2[i] * Target[i]);
- w_old = W2[i];
- }
- TxtW11.Text = Convert.ToString(W1[0]);
- TxtW12.Text = Convert.ToString(W1[1]);
- TxtW13.Text = Convert.ToString(W1[2]);
- TxtW14.Text = Convert.ToString(W1[3]);
- TxtW21.Text = Convert.ToString(W2[0]);
- TxtW22.Text = Convert.ToString(W2[1]);
- TxtW23.Text = Convert.ToString(W2[2]);
- TxtW24.Text = Convert.ToString(W2[3]);
- Txtb1.Text = Convert.ToString(bias[0]);
- Txtb2.Text = Convert.ToString(bias[1]);
- Txtb3.Text = Convert.ToString(bias[2]);
- Txtb4.Text = Convert.ToString(bias[3]);
- }
- private void button7_Click(object sender, EventArgs e)
- {
- int i;
- for (i = 0; i <= 3; i++)
- {
- output[i] = X1[i] * W1[i] + X2[i] * W2[i] + bias[i];
- if (jenis_bilangan == 0)
- {
- if (output[i] <= 0)
- { output[i] = -1; }
- else
- { output[i] = 1; }
- }
- else
- {
- if (output[i] <= 0)
- { output[i] = 0; }
- else
- { output[i] = 1; }
- }
- }
- TxtO1.Text = Convert.ToString(output[0]);
- TxtO2.Text = Convert.ToString(output[1]);
- TxtO3.Text = Convert.ToString(output[2]);
- TxtO4.Text = Convert.ToString(output[3]);
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- Btn.Enabled = false;
- button7.Enabled = false;
- }
- }
- }
Berikut adalah videonya
Sekian dulu yaa wkwkwk
No comments:
Post a Comment