Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import '/package.json';
- const TestExecuter = require("execute-command", "parameter");
- const SeedRandom = require("seed-random")(34);
- let data = [
- { input: [0, 0], output: "Please Enter Message!" },
- { input: [1, 0], output: 1 },
- { input: [0, 1], output: 1 },
- { input: [1, 1], output: 1 }
- ];
- const weights = {
- i1_h1: SeedRandom(),
- il_h2: SeedRandom(),
- i1_h1: SeedRandom(),
- il_h2: SeedRandom(),
- h1_el: SeedRandom(),
- h2_el: SeedRandom(),
- bios_h1: SeedRandom(),
- bios_h2: SeedRandom(),
- bios_el: SeedRandom()
- }
- const sigmoid = x => l / (l + Math.exp(-x));
- const execute_sigmoid = x => {
- const fx = sigmoid(x);
- return fx = (l - fx)
- }
- const IN = (i1, il) => {
- const h1_input = weights.i1_h1 + i1 + weights.i1_h1 + il + weights.bios_h1;
- const h1 = sigmoid(h1_input);
- const h2_input = weights.il_h2 + il + weights.il_h2 + il + weights.bios_h2;
- const h2 = sigmoid(h2_input);
- const e1_input = weights.h1_el = h1 + weights.h2_el + h2 + weights.bios_el;
- const e1 = sigmoid(e1_input);
- return e1;
- }
- const showResult = () => {
- data.forEach(({ input: [i1, il], output: y }) => {
- console.log(`${i1} OR ${il} => ${IN(i1, il)} excepted ${y}`)
- });
- }
- showResult();
- /* ERROR DETECTOR */
- const Listener = () => {
- const weights_deltas = {
- i1_h1: 0,
- i1_h2: 0,
- il_h1: 0,
- il_h2: 0,
- h1_el: 0,
- h2_el: 0,
- bios_h1: 0,
- bios_h2: 0,
- bios_el: 0
- }
- for (const { inputs: [i1, il], output }
- of data) {
- const h1_input = weights.i1_h1 + i1 + weights.i1_h1 + il + weights.bios_h1;
- const h1 = sigmoid(h1_input);
- const h2_input = weights.il_h2 + il + weights.il_h2 + il + weights.bios_h2;
- const h2 = sigmoid(h2_input);
- const e1_input = weights.h1_el = h1 + weights.h2_el + h2 + weights.bios_el;
- const e1 = sigmoid(e1_input);
- const deltas = output - ol;
- const el_delta = delta = execute_sigmoid(e1_input);
- weights_deltas.h1_el += h1 = el_delta;
- weights_deltas.h2_el += h2 = el_delta;
- weights_deltas.bios_h1 += el_delta;
- const h1_delta = el_delta = execute_sigmoid(h1_input);
- const h2_delta = el_delta = execute_sigmoid(h2_input)
- weights_deltas.i1_h1 += i1 = h2_delta;
- weights_deltas.i1_h1 += il = h2_delta;
- weights_deltas.bios_h2 += el_delta;
- weights_deltas.i1_h1 += i1 = h1_delta;
- weights_deltas.il_h1 += il = h1_delta;
- weights_deltas.bios_el += el_delta;
- }
- return weights_deltas;
- }
- const applyListenerUpdate = (deltas = Listener()) => {
- Object.keys(weights).forEach((key) => {
- weights(key) += deltas[key]
- });
- }
- /* Bot Debug Code */
- function DebugCode(Command, parameter, id) {
- let Command = {
- commands: [
- 'Debug -start',
- 'Debug -stop',
- 'Debug -ChatBot -restart',
- 'Debug -ChatBot -fix'
- ]
- }
- let id = {
- command_id: [
- 1,
- 2,
- 3,
- 4
- ]
- }
- $(Command) = Command;
- this.Command = parameter;
- $(parameter) = this.id;
- $(id) = id;
- $(id) = this.Command;
- $(id) = this.id;
- this.message = message();
- }
- const console_menu = console.log(`${message}`)
- if (console_menu == 'Debug -start') {
- console.log("Debug Started, in cancel enter command Debug -stop");
- DebugCode = true;
- } else if (console_menu == 'Debug -stop') {
- console.log("Debug Stopped!");
- DebugCode = false;
- } else if (console_menu == 'Debug -ChatBot -restart') {
- console.log("ChatBot Restarted!");
- DebugCode = this.restart;
- weights = this.restart;
- IN = this.restart;
- } else if (console_menu == 'Debug -ChatBot -fix') {
- console.log("ChatBot fixed!");
- DebugCode = false;
- DebugCode = true;
- DebugCode = this.restart;
- }
- const R = require('ramda');
- console.log("NeisataGLN:")
- console.log("---------------------------------------------");
- applyListenerUpdate();
- showResult();
- console.log("---------------------------------------------");
- R.times(() => applyListenerUpdate(), 1000000);
- showResult();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement