Comparar commits
12 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| 0b31eed0d1 | |||
| a5fbefea5a | |||
| 3d8265d804 | |||
| 34c93cb718 | |||
| d3e2ea8488 | |||
| 4cfd5a828f | |||
| 24807634e8 | |||
| ebac6d8c33 | |||
| b0a9559beb | |||
| 5a6c487102 | |||
| 9a06d558aa | |||
| 0a544dbc9e |
@@ -1,4 +1,5 @@
|
||||
language: node_js
|
||||
script: "npm run test:travis"
|
||||
node_js:
|
||||
# always latest release
|
||||
- "node"
|
||||
|
||||
+9
-7
@@ -1,6 +1,8 @@
|
||||
Synaptic [](https://travis-ci.org/cazala/synaptic)
|
||||
Synaptic [](https://travis-ci.org/cazala/synaptic) [](https://synaptic-slack-ugiqacqvmd.now.sh/)
|
||||
========
|
||||
|
||||
## Important: [Synaptic 2.x](https://github.com/cazala/synaptic/issues/140) is in stage of discussion now! Feel free to participate
|
||||
|
||||
Synaptic is a javascript neural network library for **node.js** and the **browser**, its generalized algorithm is architecture-free, so you can build and train basically any type of first order or even [second order neural network](http://en.wikipedia.org/wiki/Recurrent_neural_network#Second_Order_Recurrent_Neural_Network) architectures.
|
||||
|
||||
This library includes a few built-in architectures like [multilayer perceptrons](http://en.wikipedia.org/wiki/Multilayer_perceptron), [multilayer long-short term memory](http://en.wikipedia.org/wiki/Long_short_term_memory) networks (LSTM), [liquid state machines](http://en.wikipedia.org/wiki/Liquid_state_machine) or [Hopfield](http://en.wikipedia.org/wiki/Hopfield_network) networks, and a trainer capable of training any given network, which includes built-in training tasks/tests like solving an XOR, completing a Distracted Sequence Recall task or an [Embedded Reber Grammar](http://www.willamette.edu/~gorr/classes/cs449/reber.html) test, so you can easily test and compare the performance of different architectures.
|
||||
@@ -24,12 +26,12 @@ You may also want to take a look at [this article](http://blog.webkid.io/neural-
|
||||
|
||||
####Demos
|
||||
|
||||
- [Solve an XOR](http://synaptic.juancazala.com/#/xor)
|
||||
- [Discrete Sequence Recall Task](http://synaptic.juancazala.com/#/dsr)
|
||||
- [Learn Image Filters](http://synaptic.juancazala.com/#/image-filters)
|
||||
- [Paint an Image](http://synaptic.juancazala.com/#/paint-an-image)
|
||||
- [Self Organizing Map](http://synaptic.juancazala.com/#/self-organizing-map)
|
||||
- [Read from Wikipedia](http://synaptic.juancazala.com/#/wikipedia)
|
||||
- [Solve an XOR](http://caza.la/synaptic/#/xor)
|
||||
- [Discrete Sequence Recall Task](http://caza.la/synaptic/#/dsr)
|
||||
- [Learn Image Filters](http://caza.la/synaptic/#/image-filters)
|
||||
- [Paint an Image](http://caza.la/synaptic/#/paint-an-image)
|
||||
- [Self Organizing Map](http://caza.la/synaptic/#/self-organizing-map)
|
||||
- [Read from Wikipedia](http://caza.la/synaptic/#/wikipedia)
|
||||
|
||||
The source code of these demos can be found in [this branch](https://github.com/cazala/synaptic/tree/gh-pages/scripts).
|
||||
|
||||
|
||||
externo
+27
-32
@@ -91,21 +91,14 @@
|
||||
/************************************************************************/
|
||||
/******/ ([
|
||||
/* 0 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
module.exports = __webpack_require__(1);
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 1 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var Synaptic = {
|
||||
Neuron: __webpack_require__(2),
|
||||
Layer: __webpack_require__(4),
|
||||
Network: __webpack_require__(5),
|
||||
Trainer: __webpack_require__(6),
|
||||
Architect: __webpack_require__(7)
|
||||
Neuron: __webpack_require__(1),
|
||||
Layer: __webpack_require__(3),
|
||||
Network: __webpack_require__(4),
|
||||
Trainer: __webpack_require__(5),
|
||||
Architect: __webpack_require__(6)
|
||||
};
|
||||
|
||||
// CommonJS & AMD
|
||||
@@ -136,7 +129,7 @@
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 2 */
|
||||
/* 1 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
/* WEBPACK VAR INJECTION */(function(module) {// export
|
||||
@@ -936,10 +929,10 @@
|
||||
}
|
||||
})();
|
||||
|
||||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3)(module)))
|
||||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)(module)))
|
||||
|
||||
/***/ },
|
||||
/* 3 */
|
||||
/* 2 */
|
||||
/***/ function(module, exports) {
|
||||
|
||||
module.exports = function(module) {
|
||||
@@ -955,15 +948,15 @@
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 4 */
|
||||
/* 3 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
/* WEBPACK VAR INJECTION */(function(module) {// export
|
||||
if (module) module.exports = Layer;
|
||||
|
||||
// import
|
||||
var Neuron = __webpack_require__(2)
|
||||
, Network = __webpack_require__(5)
|
||||
var Neuron = __webpack_require__(1)
|
||||
, Network = __webpack_require__(4)
|
||||
|
||||
/*******************************************************************************************
|
||||
LAYER
|
||||
@@ -1235,19 +1228,19 @@
|
||||
}
|
||||
})();
|
||||
|
||||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3)(module)))
|
||||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)(module)))
|
||||
|
||||
/***/ },
|
||||
/* 5 */
|
||||
/* 4 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
/* WEBPACK VAR INJECTION */(function(module) {// export
|
||||
if (module) module.exports = Network;
|
||||
|
||||
// import
|
||||
var Neuron = __webpack_require__(2)
|
||||
, Layer = __webpack_require__(4)
|
||||
, Trainer = __webpack_require__(6)
|
||||
var Neuron = __webpack_require__(1)
|
||||
, Layer = __webpack_require__(3)
|
||||
, Trainer = __webpack_require__(5)
|
||||
|
||||
/*******************************************************************************************
|
||||
NETWORK
|
||||
@@ -1887,10 +1880,10 @@
|
||||
return new Network(layers);
|
||||
};
|
||||
|
||||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3)(module)))
|
||||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)(module)))
|
||||
|
||||
/***/ },
|
||||
/* 6 */
|
||||
/* 5 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
/* WEBPACK VAR INJECTION */(function(module) {// export
|
||||
@@ -1969,6 +1962,7 @@
|
||||
testSet = set.slice(numTrain);
|
||||
}
|
||||
|
||||
var lastError = 0;
|
||||
while ((!abort && iterations < this.iterations && error > this.error)) {
|
||||
if (crossValidate && error <= this.crossValidate.testError) {
|
||||
break;
|
||||
@@ -1984,7 +1978,7 @@
|
||||
}
|
||||
|
||||
if(typeof this.rate === 'function') {
|
||||
currentRate = this.rate(iterations, error);
|
||||
currentRate = this.rate(iterations, lastError);
|
||||
}
|
||||
|
||||
if (crossValidate) {
|
||||
@@ -1998,6 +1992,7 @@
|
||||
|
||||
// check error
|
||||
error /= currentSetSize;
|
||||
lastError = error;
|
||||
|
||||
if (options) {
|
||||
if (this.schedule && this.schedule.every && iterations %
|
||||
@@ -2568,16 +2563,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3)(module)))
|
||||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)(module)))
|
||||
|
||||
/***/ },
|
||||
/* 7 */
|
||||
/* 6 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
/* WEBPACK VAR INJECTION */(function(module) {// import
|
||||
var Layer = __webpack_require__(4)
|
||||
, Network = __webpack_require__(5)
|
||||
, Trainer = __webpack_require__(6)
|
||||
var Layer = __webpack_require__(3)
|
||||
, Network = __webpack_require__(4)
|
||||
, Trainer = __webpack_require__(5)
|
||||
|
||||
/*******************************************************************************************
|
||||
ARCHITECT
|
||||
@@ -2847,7 +2842,7 @@
|
||||
|
||||
// export
|
||||
if (module) module.exports = Architect;
|
||||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3)(module)))
|
||||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)(module)))
|
||||
|
||||
/***/ }
|
||||
/******/ ]);
|
||||
externo
+2848
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -0,0 +1,25 @@
|
||||
// Karma configuration
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
basePath: '',
|
||||
frameworks: ['mocha'],
|
||||
files: [
|
||||
'dist/synaptic.js',
|
||||
'test/[^_]*.js'
|
||||
],
|
||||
exclude: [
|
||||
],
|
||||
preprocessors: {
|
||||
'test/*.js': ['webpack'],
|
||||
},
|
||||
reporters: ['progress'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: config.LOG_INFO,
|
||||
autoWatch: true,
|
||||
singleRun: false,
|
||||
concurrency: Infinity,
|
||||
browserNoActivityTimeout: 60000,
|
||||
})
|
||||
}
|
||||
+18
-5
@@ -1,22 +1,35 @@
|
||||
{
|
||||
"name": "synaptic",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.9",
|
||||
"description": "architecture-free neural network library",
|
||||
"main": "./src/synaptic",
|
||||
"scripts": {
|
||||
"test": "mocha test",
|
||||
"test": "npm run test:src",
|
||||
"test:src": "mocha test --require src/synaptic.js ./test",
|
||||
"test:dist": "npm run build && npm run test:mocha:dist && npm run test:karma:browsers",
|
||||
"test:mocha:src": "mocha test --require src/synaptic.js ./test",
|
||||
"test:mocha:dist": "mocha test --require dist/synaptic.js ./test",
|
||||
"test:karma:browsers": "karma start --single-run --browsers Chrome,Firefox,SafariPrivate",
|
||||
"test:karma:phantomjs": "karma start --single-run --browsers PhantomJS",
|
||||
"test:travis": "npm run test:mocha:src && npm run build && npm run test:mocha:dist",
|
||||
"build": "webpack --config webpack.config.js"
|
||||
},
|
||||
"precommit": [
|
||||
"prepush": [
|
||||
"test",
|
||||
"build"
|
||||
],
|
||||
"devDependencies": {
|
||||
"chai": "^3.5.0",
|
||||
"chai-stats": "^0.3.0",
|
||||
"karma": "^1.1.2",
|
||||
"karma-chrome-launcher": "^1.0.1",
|
||||
"karma-firefox-launcher": "^1.0.0",
|
||||
"karma-mocha": "^1.1.1",
|
||||
"karma-phantomjs-launcher": "^1.0.1",
|
||||
"karma-safari-launcher": "^1.0.0",
|
||||
"karma-webpack": "^1.7.0",
|
||||
"mocha": "^2.2.4",
|
||||
"pre-commit": "^1.1.3",
|
||||
"random-js": "^1.0.8",
|
||||
"pre-push": "^0.1.1",
|
||||
"webpack": "^1.13.1"
|
||||
},
|
||||
"repository": {
|
||||
|
||||
+3
-1
@@ -74,6 +74,7 @@ Trainer.prototype = {
|
||||
testSet = set.slice(numTrain);
|
||||
}
|
||||
|
||||
var lastError = 0;
|
||||
while ((!abort && iterations < this.iterations && error > this.error)) {
|
||||
if (crossValidate && error <= this.crossValidate.testError) {
|
||||
break;
|
||||
@@ -89,7 +90,7 @@ Trainer.prototype = {
|
||||
}
|
||||
|
||||
if(typeof this.rate === 'function') {
|
||||
currentRate = this.rate(iterations, error);
|
||||
currentRate = this.rate(iterations, lastError);
|
||||
}
|
||||
|
||||
if (crossValidate) {
|
||||
@@ -103,6 +104,7 @@ Trainer.prototype = {
|
||||
|
||||
// check error
|
||||
error /= currentSetSize;
|
||||
lastError = error;
|
||||
|
||||
if (options) {
|
||||
if (this.schedule && this.schedule.every && iterations %
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
Test using gulp, from root directory:
|
||||
Test using mocha, from root directory:
|
||||
|
||||
`gulp test`
|
||||
`mocha test`
|
||||
|
||||
To test the web version, start a web server at the root dir of this repo, then use your OS browser.
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
global.synaptic = require('../dist/synaptic');
|
||||
@@ -0,0 +1 @@
|
||||
global.synaptic = require('../src/synaptic');
|
||||
@@ -0,0 +1 @@
|
||||
[^_]*.js
|
||||
+4
-3
@@ -3,8 +3,6 @@ var chai = require('chai');
|
||||
chai.use(require('chai-stats'));
|
||||
var assert = chai.assert;
|
||||
|
||||
var synaptic = require('../src/synaptic');
|
||||
|
||||
var Perceptron = synaptic.Architect.Perceptron;
|
||||
var LSTM = synaptic.Architect.LSTM;
|
||||
var Layer = synaptic.Layer;
|
||||
@@ -425,6 +423,7 @@ describe("Optimized and Unoptimized Networks Equivalency", function () {
|
||||
|
||||
|
||||
it('should produce the same output for both networks', function () {
|
||||
this.timeout(30000);
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
var input = generateRandomArray(2);
|
||||
var target = generateRandomArray(1);
|
||||
@@ -434,7 +433,7 @@ describe("Optimized and Unoptimized Networks Equivalency", function () {
|
||||
unoptimized.propagate(learningRate, target);
|
||||
}
|
||||
var mse = calculateMse(optimized.activate(input), unoptimized.activate(input));
|
||||
assert.isAtMost(mse, 1e-10, 'output should be same for both networks after ' + i + ' iterations');
|
||||
assert.isAtMost(mse, 1e-9, 'output should be same for both networks after ' + i + ' iterations');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -447,6 +446,7 @@ describe("toJSON/fromJSON Networks Equivalency", function () {
|
||||
});
|
||||
|
||||
it('should produce the same output for both networks', function () {
|
||||
this.timeout(30000);
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
var input = generateRandomArray(10);
|
||||
var output1 = original.activate(input);
|
||||
@@ -473,6 +473,7 @@ describe("Cloned Networks Equivalency", function () {
|
||||
});
|
||||
|
||||
it('should produce the same output for both networks', function () {
|
||||
this.timeout(30000);
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
var input = generateRandomArray(10);
|
||||
var output1 = original.activate(input);
|
||||
|
||||
+5
-4
@@ -2,12 +2,13 @@ var webpack = require('webpack')
|
||||
var license = require('./prebuild.js')
|
||||
module.exports = {
|
||||
context: __dirname,
|
||||
entry: [
|
||||
'./src/synaptic.js'
|
||||
],
|
||||
entry: {
|
||||
synaptic: './src/synaptic.js',
|
||||
'synaptic.min': './src/synaptic.js'
|
||||
},
|
||||
output: {
|
||||
path: 'dist',
|
||||
filename: 'synaptic.js',
|
||||
filename: '[name].js',
|
||||
},
|
||||
plugins: [
|
||||
new webpack.NoErrorsPlugin(),
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário