From 92a96a82b9029b00fbd4ccef1ff3970518db25bb Mon Sep 17 00:00:00 2001 From: Christian Hodgden Date: Fri, 9 Feb 2024 16:27:50 +0000 Subject: added module imports and describe() method to nnetwork testing --- src/nnetwork.js | 5 ++++- test/reports/coverage.txt | 3 ++- test/unit_tests/nnetwork.test.js | 33 +++++++++++++++++++++------------ 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/nnetwork.js b/src/nnetwork.js index dd21491..97b4ea5 100644 --- a/src/nnetwork.js +++ b/src/nnetwork.js @@ -1,4 +1,5 @@ -console.log('Hello from nnetwork.js'); +const math = require('mathjs'); +const Layer = require('./layer'); class NNetwork { constructor(nodeCounts, activationFunctionNames, learningRate) { @@ -34,3 +35,5 @@ class NNetwork { this.layers.reverse() } }; + +module.exports = NNetwork; \ No newline at end of file diff --git a/test/reports/coverage.txt b/test/reports/coverage.txt index 38557e5..255fa17 100644 --- a/test/reports/coverage.txt +++ b/test/reports/coverage.txt @@ -1,8 +1,9 @@ ------------------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ------------------------|---------|----------|---------|---------|------------------- -All files | 82.29 | 100 | 87.5 | 81.72 | +All files | 67.76 | 100 | 65.62 | 68.1 | activationFunctions.js | 100 | 100 | 100 | 100 | binaryConverter.js | 97.29 | 100 | 90 | 97.22 | 45 layer.js | 52.94 | 100 | 60 | 51.51 | 26-53 + nnetwork.js | 12 | 100 | 0 | 13.04 | 6-35 ------------------------|---------|----------|---------|---------|------------------- diff --git a/test/unit_tests/nnetwork.test.js b/test/unit_tests/nnetwork.test.js index efc3f6e..d7d9348 100644 --- a/test/unit_tests/nnetwork.test.js +++ b/test/unit_tests/nnetwork.test.js @@ -1,17 +1,26 @@ -console.log('Hello from nnetwork.test.js'); +const BinaryConverter = require('../../src/binaryConverter'); +const NNetwork = require('../../src/nnetwork'); +const math = require('mathjs'); -let testConv = new BinaryConverter(2); -let nodeCounts = [testConv._inputDigits, 3, testConv._outputDigits]; -let afns = ['identity', 'relu', 'identity']; +describe('Test NNetwork module', () => { -let testNNetwork = new NNetwork(nodeCounts, afns, 0.1); + // let testConv = new BinaryConverter(2); + // let nodeCounts = [testConv._inputDigits, 3, testConv._outputDigits]; + // let afns = ['identity', 'relu', 'identity']; + + // let testNNetwork = new NNetwork(nodeCounts, afns, 0.1); + + // testConv.randomInput(); + // testNNetwork.forwardPropogation(testConv.inputActivation); + // testNNetwork.backPropogation(testConv.inputActivation, testConv.outputActivation); + + // testConv.randomInput(); + // testNNetwork.forwardPropogation(testConv.inputActivation); + // testNNetwork.backPropogation(testConv.inputActivation, testConv.outputActivation); + + // testNNetwork.gradientDescent(); -console.log(testConv.randomInput()); -console.log(testNNetwork.forwardPropogation(testConv.inputActivation)); -console.log(testNNetwork.backPropogation(testConv.inputActivation, testConv.outputActivation)); + test.todo('NNetwork Tests'); -console.log(testConv.randomInput()); -console.log(testNNetwork.forwardPropogation(testConv.inputActivation)); -console.log(testNNetwork.backPropogation(testConv.inputActivation, testConv.outputActivation)); +}); -testNNetwork.gradientDescent(); \ No newline at end of file -- cgit v1.2.3