Skip to content

Commit d3fe884

Browse files
author
Juan Cazala
committed
build
1 parent 1fd01f2 commit d3fe884

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

dist/synaptic.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -910,18 +910,17 @@ var Network = function () {
910910
}, {
911911
key: 'worker',
912912
value: function worker(memory, set, options) {
913-
914913
// Copy the options and set defaults (options might be different for each worker)
915914
var workerOptions = {};
916915
if (options) workerOptions = options;
917-
workerOptions.rate = options.rate || .2;
918-
workerOptions.iterations = options.iterations || 100000;
919-
workerOptions.error = options.error || .005;
920-
workerOptions.cost = options.cost || null;
921-
workerOptions.crossValidate = options.crossValidate || null;
916+
workerOptions.rate = workerOptions.rate || .2;
917+
workerOptions.iterations = workerOptions.iterations || 100000;
918+
workerOptions.error = workerOptions.error || .005;
919+
workerOptions.cost = workerOptions.cost || null;
920+
workerOptions.crossValidate = workerOptions.crossValidate || null;
922921

923922
// Cost function might be different for each worker
924-
costFunction = 'var cost = ' + (options && options.cost || this.cost || _Trainer2.default.cost.MSE) + ';\n';
923+
var costFunction = '// REPLACED BY WORKER\nvar cost = ' + (options && options.cost || this.cost || _Trainer2.default.cost.MSE) + ';\n';
925924
var workerFunction = Network.getWorkerSharedFunctions();
926925
workerFunction = workerFunction.replace(/var cost = options && options\.cost \|\| this\.cost \|\| Trainer\.cost\.MSE;/g, costFunction);
927926

@@ -978,19 +977,18 @@ var Network = function () {
978977

979978
// Load and name the train function
980979
var train_f = _Trainer2.default.prototype.train.toString();
981-
train_f = train_f.replace('function (set', 'function train(set') + '\n';
980+
train_f = train_f.replace(/this._trainSet/g, '_trainSet');
981+
train_f = train_f.replace(/this.test/g, 'test');
982+
train_f = train_f.replace(/this.crossValidate/g, 'crossValidate');
983+
train_f = train_f.replace('crossValidate = true', '// REMOVED BY WORKER');
982984

983985
// Load and name the _trainSet function
984986
var _trainSet_f = _Trainer2.default.prototype._trainSet.toString().replace(/this.network./g, '');
985-
_trainSet_f = _trainSet_f.replace('function (set', 'function _trainSet(set') + '\n';
986-
_trainSet_f = _trainSet_f.replace('this.crossValidate', 'crossValidate');
987-
_trainSet_f = _trainSet_f.replace('crossValidate = true', 'crossValidate = { }');
988987

989988
// Load and name the test function
990989
var test_f = _Trainer2.default.prototype.test.toString().replace(/this.network./g, '');
991-
test_f = test_f.replace('function (set', 'function test(set') + '\n';
992990

993-
return Network._SHARED_WORKER_FUNCTIONS = train_f + _trainSet_f + test_f;
991+
return Network._SHARED_WORKER_FUNCTIONS = train_f + '\n' + _trainSet_f + '\n' + test_f;
994992
}
995993
}, {
996994
key: 'fromJSON',

dist/synaptic.min.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -910,18 +910,17 @@ var Network = function () {
910910
}, {
911911
key: 'worker',
912912
value: function worker(memory, set, options) {
913-
914913
// Copy the options and set defaults (options might be different for each worker)
915914
var workerOptions = {};
916915
if (options) workerOptions = options;
917-
workerOptions.rate = options.rate || .2;
918-
workerOptions.iterations = options.iterations || 100000;
919-
workerOptions.error = options.error || .005;
920-
workerOptions.cost = options.cost || null;
921-
workerOptions.crossValidate = options.crossValidate || null;
916+
workerOptions.rate = workerOptions.rate || .2;
917+
workerOptions.iterations = workerOptions.iterations || 100000;
918+
workerOptions.error = workerOptions.error || .005;
919+
workerOptions.cost = workerOptions.cost || null;
920+
workerOptions.crossValidate = workerOptions.crossValidate || null;
922921

923922
// Cost function might be different for each worker
924-
costFunction = 'var cost = ' + (options && options.cost || this.cost || _Trainer2.default.cost.MSE) + ';\n';
923+
var costFunction = '// REPLACED BY WORKER\nvar cost = ' + (options && options.cost || this.cost || _Trainer2.default.cost.MSE) + ';\n';
925924
var workerFunction = Network.getWorkerSharedFunctions();
926925
workerFunction = workerFunction.replace(/var cost = options && options\.cost \|\| this\.cost \|\| Trainer\.cost\.MSE;/g, costFunction);
927926

@@ -978,19 +977,18 @@ var Network = function () {
978977

979978
// Load and name the train function
980979
var train_f = _Trainer2.default.prototype.train.toString();
981-
train_f = train_f.replace('function (set', 'function train(set') + '\n';
980+
train_f = train_f.replace(/this._trainSet/g, '_trainSet');
981+
train_f = train_f.replace(/this.test/g, 'test');
982+
train_f = train_f.replace(/this.crossValidate/g, 'crossValidate');
983+
train_f = train_f.replace('crossValidate = true', '// REMOVED BY WORKER');
982984

983985
// Load and name the _trainSet function
984986
var _trainSet_f = _Trainer2.default.prototype._trainSet.toString().replace(/this.network./g, '');
985-
_trainSet_f = _trainSet_f.replace('function (set', 'function _trainSet(set') + '\n';
986-
_trainSet_f = _trainSet_f.replace('this.crossValidate', 'crossValidate');
987-
_trainSet_f = _trainSet_f.replace('crossValidate = true', 'crossValidate = { }');
988987

989988
// Load and name the test function
990989
var test_f = _Trainer2.default.prototype.test.toString().replace(/this.network./g, '');
991-
test_f = test_f.replace('function (set', 'function test(set') + '\n';
992990

993-
return Network._SHARED_WORKER_FUNCTIONS = train_f + _trainSet_f + test_f;
991+
return Network._SHARED_WORKER_FUNCTIONS = train_f + '\n' + _trainSet_f + '\n' + test_f;
994992
}
995993
}, {
996994
key: 'fromJSON',

0 commit comments

Comments
 (0)