From 9cd43d5ee55883ddf7afd7616fdf312b83cabb0d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 22 Feb 2021 10:22:55 +0100 Subject: [PATCH] Docs remembering last page when tab is closed --- .../LearningSimulation.js | 2 ++ .../Low-Frequency-Learning/LearningSystem.js | 5 +++++ .../UI/Spaces/Docs-Space/DocsSpace.js | 1 - .../TensorFlowLibrary.js | 21 ++++++++++++++++--- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningSimulation.js b/Projects/Superalgos/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningSimulation.js index ea0509c0c..1180b6821 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningSimulation.js +++ b/Projects/Superalgos/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningSimulation.js @@ -268,6 +268,8 @@ exports.newSuperalgosBotModulesLearningSimulation = function (processIndex) { } } + await learningSystemModuleObject.saveModel() + learningSystemModuleObject.finalize() learningRecordsModuleObject.finalize() learningEpisodeModuleObject.finalize() 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 4826253b1..cd8cfe6e1 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 @@ -5,6 +5,7 @@ exports.newSuperalgosBotModulesLearningSystem = function (processIndex) { */ const MODULE_NAME = 'Learning System' let thisObject = { + saveModel: saveModel, mantain: mantain, reset: reset, run: run, @@ -182,6 +183,10 @@ exports.newSuperalgosBotModulesLearningSystem = function (processIndex) { learningEngine = undefined sessionParameters = undefined } + + async function saveModel() { + await machineLearningLibraryModuleObject.saveModel() + } function mantain() { machineLearningLibraryModuleObject.mantain() diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js index 8ab22970f..9976c4bd9 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js @@ -272,7 +272,6 @@ function newSuperalgosDocSpace() { function onClosing() { thisObject.contextMenu.removeContextMenuFromScreen() - UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered = undefined thisObject.isVisible = false } 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 04e7e7e3a..e19039f19 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 @@ -2,6 +2,7 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { const MODULE_NAME = 'Time Series Forcasting Tensor Flow JS Learning Algorithm' let thisObject = { + saveModel: saveModel, updateChart: updateChart, mantain: mantain, reset: reset, @@ -112,6 +113,7 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { break } case 'Functional Model': { + /* To be implemented some day...*/ break } } @@ -119,6 +121,7 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { } case 'Code API': { tensorFlowAPI = require("@tensorflow/tfjs-core") + /* To be implemented some day...*/ break } } @@ -309,6 +312,18 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { tensorFlowData = undefined } + async function saveModel() { + + let fileName = learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.config.codeName + let filePath = + global.env.PATH_TO_DATA_STORAGE + '/' + + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).FILE_PATH_ROOT + + '/Output/' + + TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_FOLDER_NAME // + '/' + 'Model' + + await tensorFlowModel.save('file://' + filePath + '/' + fileName) + } + function updateChart(pChart, pExchange, pMarket) { /* We need these 3 data structures to be a local objects @@ -371,12 +386,12 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { tensorFlowData = require("@tensorflow/tfjs-data") function* featuresGenerator() { - console.log('Features: ' + features) + //console.log('Features: ' + features) yield features } function* labelsGenerator() { - console.log('Labels: ' + labels) + //console.log('Labels: ' + labels) yield labels } @@ -408,7 +423,7 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { epochs: ecpochs }) - tensorFlowModel.summary() + //tensorFlowModel.summary() }