Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 463705a

Browse files
authored
Merge pull request antoniodeluca#14 from antoniodeluca/master
Minor improvements and environment configuration for tests. First test containers have been added.
2 parents fa67833 + fb2aea7 commit 463705a

File tree

16 files changed

+262
-23
lines changed

16 files changed

+262
-23
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/bower_components
22
/node_modules
33
/built
4-
/bundle
4+
/bundled

.travis.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
language: node_js
2+
node_js:
3+
- "6.1"
4+
- "6.0"
5+
- "5.11"
6+
- "5.10"
7+
- "5.9"
8+
- "5.8"
9+
- "5.7"
10+
- "5.6"
11+
- "5.5"
12+
- "5.4"
13+
- "5.3"
14+
- "5.2"
15+
- "5.1"
16+
- "5.0"
17+
- "4.4"
18+
- "4.3"
19+
- "4.2"
20+
- "4.1"
21+
- "4.0"
22+
before_script:
23+
- npm install grunt-cli -g
24+
- npm install

Gruntfile.js

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@
33
module.exports = function(grunt) {
44
grunt.initConfig({
55
pkg: grunt.file.readJSON("package.json"),
6+
babel: {
7+
options: {
8+
sourceMap: false,
9+
presets: ["es2015"]
10+
},
11+
dist: {
12+
files: {
13+
"built/networks/alpha.js": "library/networks/alpha.js",
14+
"built/bios.js": "library/bios.js",
15+
"built/brain.js": "library/brain.js",
16+
"built/cerebrum.js": "library/cerebrum.js",
17+
"built/dn2a.js": "library/dn2a.js",
18+
"built/host.js": "library/host.js",
19+
"built/link.js": "library/link.js",
20+
"built/neuron.js": "library/neuron.js",
21+
"built/node.js": "library/node.js",
22+
"built/synapse.js": "library/synapse.js"
23+
}
24+
}
25+
},
626
browserify: {
727
options: {
828
browserifyOptions: {
@@ -11,17 +31,58 @@
1131
},
1232
dist: {
1333
files: {
14-
"bundle/dn2a.browser.js": ["built/dn2a.js"]
34+
"bundled/dn2a.browser.js": ["built/dn2a.js"]
1535
}
1636
}
37+
},
38+
clean: {
39+
builtFolder: {
40+
src: ["built/**/*"]
41+
},
42+
bundledFolder: {
43+
src: ["bundled/**/*"]
44+
}
45+
},
46+
karma: {
47+
options: {
48+
configFile: "karma.conf.js"
49+
},
50+
unitMode: {
51+
singleRun: true
52+
},
53+
continuousMode: {
54+
singleRun: false,
55+
autoWatch: false
56+
}
1757
}
1858
});
59+
grunt.loadNpmTasks("grunt-babel");
1960
grunt.loadNpmTasks("grunt-browserify");
61+
grunt.loadNpmTasks("grunt-contrib-clean");
62+
grunt.loadNpmTasks("grunt-karma");
63+
grunt.registerTask(
64+
"build",
65+
[
66+
"clean:builtFolder",
67+
"babel"
68+
]
69+
);
2070
grunt.registerTask(
2171
"bundle",
2272
[
73+
"clean:builtFolder",
74+
"clean:bundledFolder",
75+
"babel",
2376
"browserify"
2477
]
2578
);
79+
grunt.registerTask(
80+
"test",
81+
[
82+
"clean:builtFolder",
83+
"babel",
84+
"karma:unitMode"
85+
]
86+
);
2687
};
2788
}());

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# DN2A - Digital Neural Network Architecture #
22

3+
[![Build Status](https://travis-ci.org/dn2a/dn2a-javascript.svg?branch=master)](https://travis-ci.org/dn2a/dn2a-javascript)
4+
35
---
46

57
## About ##
@@ -17,8 +19,8 @@ DN2A aims to allow you to create and train simple Neural Networks as well as ver
1719
- **Modularized components**: helps the development and the clear separation of concerns with great benefits for who wants to use mixed solutions.
1820
- **Configurable computation precision**: helps to avoid the noise deriving from operation errors and default system precision limits with great improvement of the learning speed and performance stability.
1921
- **Configuration checker**: helps to write less details about configuration and to keep compatibility with older version while the project evolves.
20-
- **StepByStep or Continuous training**: helps to train neural networks without being limited to a particular approach for the greater good of projects with very complex project's needs.
21-
- TODO (Bios) **Data normalization**: helps to simplify the interaction within your real domain.
22+
- **StepByStep or Continuous training**: helps to train neural networks without being limited to a particular approach for the greater good of projects with very complex project's needs.
23+
- TODO (Bios) **Data normalization**: helps to simplify the interaction within your real domain.
2224
- TODO (Host) **Networks composition**: helps to create very effective architectures of multiple neural networks able to obtain advanced behaviours like in deep learning.
2325
- TODO (Host) **Computation parallelization**: helps to improve the scalability of your whole system.
2426
- TODO (Bios) **Sessions intercommunication**: helps to improve the scalability of your whole system.
@@ -126,12 +128,12 @@ To import through your preferred loader configure it to point to the right place
126128

127129
### Training/Querying a Network with default parametrization ###
128130

129-
// Importation
131+
// Importation
130132
var DN2A = require("dn2a");
131-
133+
132134
// Instantiation
133135
var neuralNetwork = new DN2A.NetworkAlpha();
134-
136+
135137
// Training
136138
var trainingPatterns = [
137139
{
@@ -152,7 +154,7 @@ To import through your preferred loader configure it to point to the right place
152154
}
153155
];
154156
neuralNetwork.train(trainingPatterns);
155-
157+
156158
// Querying
157159
//
158160
// The object passed to the callback function contains information about the querying process.
@@ -172,13 +174,13 @@ To import through your preferred loader configure it to point to the right place
172174

173175
// Importation
174176
// ...
175-
177+
176178
// Instantiation
177179
//
178-
// The object passed to the constructor function contains properties describing the neural network.
180+
// The object passed to the constructor function contains properties describing the neural network.
179181
// The list of the properties is reported in the main README file.
180-
// In case one or more properties are not present they are substituted with defaults.
181-
// Same thing happens if the object is not passed at all.
182+
// In case one or more properties are not present they are substituted with defaults.
183+
// Same thing happens if the object is not passed at all.
182184
var neuralNetwork = new DN2A.NetworkAlpha({
183185
layerDimensions: [2, 4, 4, 1], // the default would be [2, 4, 1]
184186
learningMode: "continuous",
@@ -195,21 +197,21 @@ To import through your preferred loader configure it to point to the right place
195197
},
196198
numbersPrecision: 32
197199
});
198-
200+
199201
// Training
200202
// ...
201-
203+
202204
// Querying
203205
// ...
204206

205207
### Training/Querying a Network with evolution feedback ###
206208

207209
// Importation
208210
// ...
209-
211+
210212
// Instantiation
211213
// ...
212-
214+
213215
// Training
214216
//
215217
// The object passed to the callback function contains information about the training process.
@@ -235,15 +237,15 @@ To import through your preferred loader configure it to point to the right place
235237
neuralNetwork.train(trainingPatterns, function(trainingStatus) {
236238
console.log("Epoch: " + trainingStatus.elapsedEpochCounter);
237239
});
238-
240+
239241
// Querying
240242
// ...
241243

242244
### Training/Querying a specific Network through the Host ###
243245

244246
// Importation
245247
// ...
246-
248+
247249
// Instantiation
248250
var cerebrum = new DN2A.Cerebrum({
249251
minds: [
@@ -277,7 +279,7 @@ To import through your preferred loader configure it to point to the right place
277279
"firstNeuralNetwork"
278280
]
279281
});
280-
282+
281283
// Training
282284
//
283285
// The name passed to the trainMind method specifies which specific mind to train
@@ -302,7 +304,7 @@ To import through your preferred loader configure it to point to the right place
302304
cerebrum.trainMind(trainingPatterns, function(trainingStatus) {
303305
console.log("Epoch: " + trainingStatus.elapsedEpochCounter);
304306
}, "firstNeuralNetwork");
305-
307+
306308
// Querying
307309
//
308310
// The name passed to the queryMind method specifies which specific mind to query
@@ -346,4 +348,4 @@ To import through your preferred loader configure it to point to the right place
346348

347349
# License #
348350

349-
MIT
351+
MIT

karma.conf.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
(function() {
2+
"use strict";
3+
module.exports = function (config) {
4+
config.set({
5+
autoWatch: false,
6+
basePath: "./",
7+
browsers: [
8+
"PhantomJS"
9+
],
10+
colors: true,
11+
files: [
12+
"tests/**/*.js"
13+
],
14+
frameworks: [
15+
"browserify",
16+
"jasmine",
17+
"jasmine-matchers"
18+
],
19+
plugins: [
20+
"karma-browserify",
21+
"karma-jasmine",
22+
"karma-jasmine-matchers",
23+
"karma-phantomjs-launcher"
24+
],
25+
preprocessors: {
26+
"tests/**/*.js": ["browserify"]
27+
},
28+
reporters: [
29+
"progress"
30+
],
31+
singleRun: true
32+
});
33+
};
34+
}());

package.json

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,23 @@
1212
"babel-preset-es2015": "^6.6.0",
1313
"browserify": "^13.0.0",
1414
"grunt": "^1.0.1",
15+
"grunt-babel": "^6.0.0",
1516
"grunt-cli": "^1.2.0",
1617
"grunt-contrib-clean": "^1.0.0",
17-
"grunt-browserify": "^5.0.0"
18+
"grunt-browserify": "^5.0.0",
19+
"grunt-karma": "^2.0.0",
20+
"gulp": "^3.9.1",
21+
"gulp-babel": "^6.1.2",
22+
"gulp-clean": "^0.3.2",
23+
"gulp-cli": "^1.2.2",
24+
"jasmine": "^2.4.1",
25+
"jasmine-expect": "^2.0.2",
26+
"karma": "^1.1.0",
27+
"karma-browserify": "^5.0.5",
28+
"karma-phantomjs-launcher": "^1.0.1",
29+
"karma-jasmine": "^1.0.2",
30+
"karma-jasmine-matchers": "^2.0.2",
31+
"phantomjs": "^2.1.7"
1832
},
1933
"keywords": [
2034
"neural networks",
@@ -28,7 +42,9 @@
2842
"url": "https://github.com/dn2a/dn2a-javascript.git"
2943
},
3044
"scripts": {
31-
"transpile": "babel library -d built"
45+
"build": "grunt build",
46+
"bundle": "grunt bundle",
47+
"test": "grunt test"
3248
},
3349
"version": "0.1.1"
3450
}

tests/bios.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var Bios = require("../built/bios.js").Bios;
2+
3+
describe("Bios", function () {
4+
var bios = null;
5+
6+
beforeEach(function() {
7+
bios = new Bios();
8+
});
9+
});

tests/brain.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var Brain = require("../built/brain.js").Brain;
2+
3+
describe("Brain", function () {
4+
var brain = null;
5+
6+
beforeEach(function() {
7+
brain = new Brain();
8+
});
9+
});

tests/cerebrum.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var Cerebrum = require("../built/cerebrum.js").Cerebrum;
2+
3+
describe("Cerebrum", function () {
4+
var cerebrum = null;
5+
6+
beforeEach(function() {
7+
cerebrum = new Cerebrum();
8+
});
9+
});

tests/dn2a.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var DN2A = require("../built/dn2a.js").DN2A;
2+
3+
describe("DN2A", function () {
4+
var dn2a = null;
5+
6+
beforeEach(function() {
7+
dn2a = new DN2A();
8+
});
9+
});

0 commit comments

Comments
 (0)