layerganza
Version:
A feed-forward neural network with injectable layers, activation functions, and optimizers.
19 lines (18 loc) • 815 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const arrayShuffle_1 = __importDefault(require("../math/arrayShuffle"));
function shuffleTrain(neuralNetwork, trainingSets, maxEpochs, log = () => { }) {
for (let epoch = 0; epoch < maxEpochs; epoch++) {
trainingSets = arrayShuffle_1.default(trainingSets);
for (let setI = 0, setCount = trainingSets.length; setI < setCount; setI++) {
let set = trainingSets[setI];
let outputs = neuralNetwork.invoke(set[0]);
neuralNetwork.learn(set[1]);
log(epoch, setI, set[0], set[1], outputs);
}
}
}
exports.default = shuffleTrain;