From 10e693a59f9a0c46599d1b2de04dd4a9664928e5 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 20 Feb 2021 08:33:10 +0100 Subject: [PATCH] Bug fixed with features and labels arrray --- .../Low-Frequency-Learning/LearningSystem.js | 10 +---- .../Docs-Nodes/dimensionality-units.json | 9 +++- .../TensorFlowLibrary.js | 41 +++++++++++-------- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningSystem.js b/Projects/Superalgos/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningSystem.js index 219109115..4826253b1 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningSystem.js +++ b/Projects/Superalgos/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningSystem.js @@ -236,15 +236,7 @@ exports.newSuperalgosBotModulesLearningSystem = function (processIndex) { /* Initialize the Learning Algorithm */ - machineLearningLibraryModuleObject.run(onRun) - - function onRun(err) { - if (err.result === TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { - - } else { - - } - } + await machineLearningLibraryModuleObject.run() } catch (err) { /* diff --git a/Projects/TensorFlow/Schemas/Docs-Nodes/dimensionality-units.json b/Projects/TensorFlow/Schemas/Docs-Nodes/dimensionality-units.json index 89183b32a..4203e9e9f 100644 --- a/Projects/TensorFlow/Schemas/Docs-Nodes/dimensionality-units.json +++ b/Projects/TensorFlow/Schemas/Docs-Nodes/dimensionality-units.json @@ -2,7 +2,14 @@ "type": "Dimensionality Units", "definition": { "text": "Positive integer, dimensionality of the output space.", - "updated": 1613243190046 + "updated": 1613243190046, + "translations": [ + { + "language": "CN", + "text": "Positive integer, dimensionality of the output space. In other words, the amount of neurons at the Artificial Neural Network layer.", + "updated": 1613805816485 + } + ] }, "paragraphs": [ { diff --git a/Projects/TensorFlow/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/TensorFlowLibrary.js b/Projects/TensorFlow/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/TensorFlowLibrary.js index f2fc1392f..5cf8b1bac 100644 --- a/Projects/TensorFlow/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/TensorFlowLibrary.js +++ b/Projects/TensorFlow/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/TensorFlowLibrary.js @@ -26,8 +26,6 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { let tensorFlowAPI let tensorFlowModel let tensorFlowData - let features = [] - let labels = [] return thisObject @@ -178,12 +176,16 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { if (layerNode.typeOfLayer.layer.dimensionalityUnits !== undefined) { argsObject.units = layerNode.typeOfLayer.layer.dimensionalityUnits.config.value + } else { + argsObject.units = 1 } if (layerNode.typeOfLayer.layer.activationFunction !== undefined) { argsObject.activation = layerNode.typeOfLayer.layer.activationFunction.config.value } if (layerNode.typeOfLayer.layer.bias !== undefined) { argsObject.useBias = true + } else { + argsObject.useBias = false } if (layerNode.typeOfLayer.layer.kernel !== undefined) { if (layerNode.typeOfLayer.layer.kernel.kernelInitializer !== undefined) { @@ -271,6 +273,8 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { } tensorFlowModel.compile(compileArgs) + + tensorFlowModel.summary() } } @@ -287,9 +291,6 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { tensorFlowAPI = undefined tensorFlowModel = undefined tensorFlowData = undefined - - features = [] - labels = [] } function updateChart(pChart, pExchange, pMarket) { @@ -309,10 +310,12 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { function reset() { } - function run(callbackFunction) { + async function run(callbackFunction) { let layersModel = learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.api.layersModel - + let features = [] + let labels = [] + /* Building the Features Tensor */ @@ -351,18 +354,22 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { tensorFlowData = require("@tensorflow/tfjs-data") - let dataset = tensorFlowData.array([features, labels]) + function* featuresGenerator() { + yield features + } - tensorFlowModel.fitDataset(dataset, { epochs: 5 }).then(info => { - console.log('Accuracy', info.history.acc); - - /* - if all is good, return this... - */ - callbackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) - - }); + function* labelsGenerator() { + yield labels + } + const xs = tensorFlowData.generator(featuresGenerator) + const ys = tensorFlowData.generator(labelsGenerator) + const ds = tensorFlowData.zip({xs, ys}).shuffle(1).batch(1) + + await tensorFlowModel.fitDataset(ds, { + verbose: 1, + epochs: 1 + }) /*