examples/stream-example.js
function(obj) {
    console.log(`trained in ${ obj.iterations } iterations with error: ${ obj.error }`);

    const result01 = net.run([0, 1]);
    const result00 = net.run([0, 0]);
    const result11 = net.run([1, 1]);
    const result10 = net.run([1, 0]);

    assert(result01[0] > 0.9);
    assert(result00[0] < 0.1);
    assert(result11[0] < 0.1);
    assert(result10[0] > 0.9);

    console.log('0 XOR 1: ', result01);  // 0.987
    console.log('0 XOR 0: ', result00);  // 0.058
    console.log('1 XOR 1: ', result11);  // 0.087
    console.log('1 XOR 0: ', result10);  // 0.934
  }
function(obj) {
    console.log(`trained in ${ obj.iterations } iterations with error: ${ obj.error }`);

    const result01 = net.run([0, 1]);
    const result00 = net.run([0, 0]);
    const result11 = net.run([1, 1]);
    const result10 = net.run([1, 0]);

    assert(result01[0] > 0.9);
    assert(result00[0] < 0.1);
    assert(result11[0] < 0.1);
    assert(result10[0] > 0.9);

    console.log('0 XOR 1: ', result01);  // 0.987
    console.log('0 XOR 0: ', result00);  // 0.058
    console.log('1 XOR 1: ', result11);  // 0.087
    console.log('1 XOR 0: ', result10);  // 0.934
  }
function ( obj ) { console . log ( ` ${ obj . iterations } ${ obj . error } ` ) ; const result01 = net . run ( [ 0 , 1 ] ) ; const result00 = net . run ( [ 0 , 0 ] ) ; const result11 = net . run ( [ 1 , 1 ] ) ; const result10 = net . run ( [ 1 , 0 ] ) ; assert ( result01 [ 0 ] > 0.9 ) ; assert ( result00 [ 0 ] < 0.1 ) ; assert ( result11 [ 0 ] < 0.1 ) ; assert ( result10 [ 0 ] > 0.9 ) ; console . log ( '0 XOR 1: ' , result01 ) ; // 0.987 console . log ( '0 XOR 0: ' , result00 ) ; // 0.058 console . log ( '1 XOR 1: ' , result11 ) ; // 0.087 console . log ( '1 XOR 0: ' , result10 ) ; // 0.934 }
Called when the network is done training.
Called when the network is done training .