trainingData[0].input.map((value) => Float32Array.from([value]) )
it('processes array same as net w/ inputSize of 1', () => { const data = [{ input: [1, 2], output: [3, 4] }]; const net = new LSTMTimeStep({ inputSize: 1, hiddenLayers: [10], outputSize: 1, }); net.train(data, { iteration: 100, errorThresh: 0.05 }); const fn = net.toFunction(istanbulLinkerUtil); const expected = net.run(data[0].input); const result = fn(data[0].input); expect(typeof result).toBe('number'); expect(result).toEqual(expected); });
const net = new NeuralNetworkGPU(); net.train(xorTrainingData, { iterations: 5000, errorThresh: 0.01 }); const target = xorTrainingData.map((datum) => net.run(datum.input)); const json = net.toJSON(); const net2 = new NeuralNetworkGPU(); net2.fromJSON(json); const output = xorTrainingData.map((datum) => net2.run(datum.input)); expect(output).toEqual(target); }); const net = new NeuralNetworkGPU(); net.train(xorTrainingData, { iterations: 5000, errorThresh: 0.01 }); const target = xorTrainingData.map((datum) => net.run(datum.input)); const json = net.toJSON(); const net2 = new NeuralNetwork(); expect(net2.run(xorTrainingData[i].input)[0]).toBeCloseTo( target[i][0], const net = new NeuralNetwork(); net.train(xorTrainingData, { iterations: 5000, errorThresh: 0.01 }); const target = xorTrainingData.map((datum) => net.run(datum.input)); const json = net.toJSON(); const net2 = new NeuralNetworkGPU(); expect(net2.run(xorTrainingData[i].input)[0]).toBeCloseTo( target[i][0],
it('processes array,object same as net', () => { const data = [ { input: [ { a: 1, b: 4 }, { a: 2, b: 3 }, ], output: [ { c: 3, d: 2 }, { c: 4, d: 1 }, ], }, ]; const net = new LSTMTimeStep({ inputSize: 2, hiddenLayers: [10], outputSize: 2, }); net.train(data, { iteration: 100, errorThresh: 0.05 }); const fn = net.toFunction(istanbulLinkerUtil); const expected = net.run(data[0].input); expect(fn(data[0].input)).toEqual(expected); });
() => { for (const i in trainingData) { const output = net.run(trainingData[i].input); const target = trainingData[i].output; return testTrainer(net, { data: not, errorThresh }).then(() => { for (const i in not) { const output = net.run(not[i].input)[0]; const target = not[i].output[0]; expect( return testTrainer(net, { data: xor, errorThresh }).then(() => { for (const i in xor) { const output = net.run(xor[i].input)[0]; const target = xor[i].output[0]; expect( return testTrainer(net, { data: or, errorThresh }).then(() => { for (const i in or) { const output = net.run(or[i].input)[0]; const target = or[i].output[0]; expect( return testTrainer(net, { data: and, errorThresh }).then(() => { for (const i in and) { const output = net.run(and[i].input)[0]; const target = and[i].output[0]; expect(
/** * Initializes an array clone. * * @private * @param {Array} array The array to clone. * @returns {Array} Returns the initialized clone. */ function initCloneArray(array) { var length = array.length, result = array.constructor(length); // Add properties assigned by `RegExp#exec`. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { result.index = array.index; result.input = array.input; } return result; }
_.times(set.length, (index) => { let input = set[index].input; let target = set[index].output; let output = self.activate(input, { trace: false }); error += cost(target, output); });
trainingData[1].input.map((value) => Float32Array.from(value) )
trainingData[0].input.map((value) => Float32Array.from(value) )
trainingData[1].input.map((value) => Float32Array.from([value]) )
/** * Initializes an array clone. * * @private * @param {Array} array The array to clone. * @returns {Array} Returns the initialized clone. */ function initCloneArray(array) { var length = array.length, result = new array.constructor(length); // Add array properties assigned by `RegExp#exec`. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { result.index = array.index; result.input = array.input; } return result; }
/** * Initializes an array clone. * * @private * @param {Array} array The array to clone. * @returns {Array} Returns the initialized clone. */ function initCloneArray(array) { var length = array.length, result = array.constructor(length); // Add properties assigned by `RegExp#exec`. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { result.index = array.index; result.input = array.input; } return result; }
/** * Initializes an array clone. * * @private * @param {Array} array The array to clone. * @returns {Array} Returns the initialized clone. */ function initCloneArray(array) { var length = array.length, result = array.constructor(length); // Add properties assigned by `RegExp#exec`. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { result.index = array.index; result.input = array.input; } return result; }
/** * Initializes an array clone. * * @private * @param {Array} array The array to clone. * @returns {Array} Returns the initialized clone. */ function initCloneArray(array) { var length = array.length, result = new array.constructor(length); // Add array properties assigned by `RegExp#exec`. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { result.index = array.index; result.input = array.input; } return result; }
/** * Initializes an array clone. * * @private * @param {Array} array The array to clone. * @returns {Array} Returns the initialized clone. */ function initCloneArray(array) { var length = array.length, result = new array.constructor(length); // Add array properties assigned by `RegExp#exec`. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { result.index = array.index; result.input = array.input; } return result; }