From 7bbd42ea466d24529cd27da20dc37908b93ef482 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 16 Feb 2021 12:37:49 +0100 Subject: [PATCH] TensorFlow library initialized --- Projects/ProjectsSchema.json | 20 +++--- .../Low-Frequency-Learning/LearningSystem.js | 68 +++++++++++-------- .../LearningSessionFunctions.js | 18 ++++- Projects/TensorFlow/Schemas/AppSchema.json | 2 +- .../TensorFlowLibrary.js} | 7 +- TaskServer/MultiProject.js | 12 ---- 6 files changed, 65 insertions(+), 62 deletions(-) rename Projects/{Superalgos/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/Time-Series-Forcasting/Tensor-Flow-JS/LearningAlgorithm.js => TensorFlow/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/TensorFlowLibrary.js} (91%) diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index eb89db9bc..5f20a722c 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -845,15 +845,6 @@ "fileName": "LearningSystem.js", "folderName": "Learning-Bot/Low-Frequency-Learning" } - ], - "algorithmModules": [ - { - "name": "Time Series Forcasting Tensor Flow JS", - "propertyName": "timeSeriesForcastingTensorFlowJS", - "functionName": "newSuperalgosAlgorithmModulesTimeSeriesForcastingTensorFlowJS", - "fileName": "LearningAlgorithm.js", - "folderName": "Learning-Bot/Low-Frequency-Learning/Time-Series-Forcasting/Tensor-Flow-JS" - } ] }, "CL": {} @@ -927,7 +918,16 @@ "TS": { "globals":[], "functionLibraries": [], - "utilities": [] + "utilities": [], + "botModules": [ + { + "name": "TensorFlow Library", + "propertyName": "tensorFlowLibrary", + "functionName": "newTensorFlowBotModulesTensorFlowLibrary", + "fileName": "TensorFlowLibrary.js", + "folderName": "Learning-Bot/Low-Frequency-Learning" + } + ] } } ] \ No newline at end of file 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 182363b48..382fa391c 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 @@ -26,28 +26,6 @@ exports.newSuperalgosBotModulesLearningSystem = function (processIndex) { let sessionParameters let dynamicIndicators - let learningAlgorithmName = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.learningParameters.learningAlgorithm.config.codeName - let learningAlgorithmModuleObject - /* - We will scan the project schema until we find the module that will run the algorithm - defined by the user at the UI / Session Parameters. - */ - for (let i = 0; i < TS.projects.superalgos.globals.taskConstants.PROJECTS_SCHEMA.length; i++) { - let project = TS.projects.superalgos.globals.taskConstants.PROJECTS_SCHEMA[i] - if (project.name !== TS.projects.superalgos.globals.taskConstants.PROJECT_DEFINITION_NODE.config.codeName) { continue } - for (let j = 0; j < project.TS.algorithmModules.length; j++) { - algorithmModuleDefinition = project.TS.algorithmModules[j] - if (algorithmModuleDefinition.name === learningAlgorithmName) { - - TS.projects.superalgos.globals.processVariables.TOTAL_PROCESS_INSTANCES_CREATED++ - let project = TS.projects[TS.projects.superalgos.globals.taskConstants.PROJECT_DEFINITION_NODE.config.codeName.toLowerCase()] - let botModule = project.algorithmModules[algorithmModuleDefinition.propertyName] - let moduleFunction = botModule[algorithmModuleDefinition.functionName] - learningAlgorithmModuleObject = moduleFunction(processIndex) - } - } - } - return thisObject function initialize() { @@ -121,9 +99,39 @@ exports.newSuperalgosBotModulesLearningSystem = function (processIndex) { } /* - Initialize the Learning Algorithm + Initialize the Machine Learning Library */ - learningAlgorithmModuleObject.initialize(onInitializeReady) + + let machineLearningLibrary = learningSystem.machineLearningLibrary + let machineLearningLibraryModuleObject + + if (machineLearningLibrary === undefined) { + // TODO + } + /* + We will scan the project schema until we find the machine learning library + defined by the user at the UI. + */ + for (let i = 0; i < TS.projects.superalgos.globals.taskConstants.PROJECTS_SCHEMA.length; i++) { + let projectSchemaProject = TS.projects.superalgos.globals.taskConstants.PROJECTS_SCHEMA[i] + if (projectSchemaProject.name !== machineLearningLibrary.project) { continue } + + for (let j = 0; j < projectSchemaProject.TS.botModules.length; j++) { + let botModuleDefinition = projectSchemaProject.TS.botModules[j] + + /* + We match the type of the machine learning library with the name at the project schema + */ + if (botModuleDefinition.name === machineLearningLibrary.type) { + + let project = TS.projects[machineLearningLibrary.project.toLowerCase()] + let botModule = project.botModules[botModuleDefinition.propertyName] + let moduleFunction = botModule[botModuleDefinition.functionName] + machineLearningLibraryModuleObject = moduleFunction(processIndex) + } + } + } + machineLearningLibraryModuleObject.initialize(onInitializeReady) function onInitializeReady(err) { if (err.result === TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { @@ -150,8 +158,8 @@ exports.newSuperalgosBotModulesLearningSystem = function (processIndex) { function finalize() { - learningAlgorithmModuleObject.finalize() - learningAlgorithmModuleObject = undefined + machineLearningLibraryModuleObject.finalize() + machineLearningLibraryModuleObject = undefined chart = undefined exchange = undefined @@ -175,11 +183,11 @@ exports.newSuperalgosBotModulesLearningSystem = function (processIndex) { } function mantain() { - learningAlgorithmModuleObject.mantain() + machineLearningLibraryModuleObject.mantain() } function reset() { - learningAlgorithmModuleObject.reset() + machineLearningLibraryModuleObject.reset() learningSystem.highlights = [] learningSystem.errors = [] @@ -201,7 +209,7 @@ exports.newSuperalgosBotModulesLearningSystem = function (processIndex) { exchange = pExchange market = pMarket - learningAlgorithmModuleObject.updateChart(pChart, pExchange, pMarket) + machineLearningLibraryModuleObject.updateChart(pChart, pExchange, pMarket) } function buildDynamicIndicators() { @@ -227,7 +235,7 @@ exports.newSuperalgosBotModulesLearningSystem = function (processIndex) { /* Initialize the Learning Algorithm */ - learningAlgorithmModuleObject.run(onRun) + machineLearningLibraryModuleObject.run(onRun) function onRun(err) { if (err.result === TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) { diff --git a/Projects/Superalgos/UI/Function-Libraries/LearningSessionFunctions.js b/Projects/Superalgos/UI/Function-Libraries/LearningSessionFunctions.js index 3f8111515..71efe0110 100644 --- a/Projects/Superalgos/UI/Function-Libraries/LearningSessionFunctions.js +++ b/Projects/Superalgos/UI/Function-Libraries/LearningSessionFunctions.js @@ -62,16 +62,28 @@ function newSuperalgosFunctionLibraryLearningSessionFunctions() { let lightingPath = '' + 'Learning System->' + - 'Tensor Flow Library->' + + 'TensorFlow Library->' + 'Execution Environmnet->Supervised Learning->Unsupervised Learning->Self Learning->Reinforcement Learning->' + 'WebGL Backend->NodeJS Backend->WASM Backend->CPU Backend->' + - 'Environment Flags->Debug Mode->Production Mode' + 'Environment Flags->Debug Mode->Production Mode->' + + 'Supervised Learning->Unsupervised Learning->Self Learning->Reinforcement Learning->' + + 'Artificial Neural Network->Model->' + + 'Layers API->Code API->' + + 'Secuential Model->Functional Model->' + + 'Input Layer->Secuential Layer->Output Layer->'+ + 'Input Shape->Batch Input Shape->Input Features->Feature->Feature Formula->' + + 'Advanced Activation Layers->Basic Layers->Convolutional Layers->' + + 'Conv 1D Layer->Conv 2D Layer->Conv 2D Transpose Layer->Conv 3D Layer->Cropping 2D Layer->Depthwise Convo 2D Layer->Separable Convo 2D Layer->Up Sampling 2D Layer->' + + 'Activation Layer->Dense Layer->Dropout Layer->Embedding Layer->Flatten Layer->Permutable Layer->Rrepeat Vector Layer->Reshape Layer->Spatial Dropout 1D Layer->' + + 'Elu Layer->Leaky Relu Layer->Prelu Layer->Relu Layer->Softmax Layer->Thresholded Relu Layer->'+ + 'Dimensionality Units->Activation Functions->Batch Size->Dtype->Trainable->Weights->Tensor->Kernel->Bias->' + + 'Kernel Initializer->Kernel Contraint->Kernel Regularizer->' + + 'Bias Initializer->Bias Contraint->Bias Regularizer->' let learningSystem = UI.projects.superalgos.functionLibraries.protocolNode.getProtocolNode(node.learningSystemReference.payload.referenceParent, false, true, true, false, false, lightingPath) lightingPath = '' + 'Learning Engine->' + - 'Dynamic Indicators->Indicator Function->' + 'Learning Current->Learning Last->Previous->' + 'Learning Episode->' + 'Episode Base Asset->Episode Quoted Asset->Learning Episode Counters->Learning Episode Statistics->' + diff --git a/Projects/TensorFlow/Schemas/AppSchema.json b/Projects/TensorFlow/Schemas/AppSchema.json index f2335536a..975eb2560 100644 --- a/Projects/TensorFlow/Schemas/AppSchema.json +++ b/Projects/TensorFlow/Schemas/AppSchema.json @@ -525,7 +525,7 @@ "action": "Add UI Object", "disableIfPropertyIsDefined": true, "propertyToCheckFor": "layerType", - "label": "Add Advanced Activation Layers", + "label": "Add Activation Layers", "relatedUiObject": "Advanced Activation Layers", "actionFunction": "payload.executeAction" }, diff --git a/Projects/Superalgos/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/Time-Series-Forcasting/Tensor-Flow-JS/LearningAlgorithm.js b/Projects/TensorFlow/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/TensorFlowLibrary.js similarity index 91% rename from Projects/Superalgos/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/Time-Series-Forcasting/Tensor-Flow-JS/LearningAlgorithm.js rename to Projects/TensorFlow/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/TensorFlowLibrary.js index 9e1a1aac8..4e3b01ec1 100644 --- a/Projects/Superalgos/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/Time-Series-Forcasting/Tensor-Flow-JS/LearningAlgorithm.js +++ b/Projects/TensorFlow/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/TensorFlowLibrary.js @@ -1,10 +1,5 @@ -exports.newSuperalgosAlgorithmModulesTimeSeriesForcastingTensorFlowJS = function (processIndex) { - /* - This module implements a learning algorithm based on Time Series Forcasting with Tensor Flow js, - as described at the folliwing web page: +exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { - https://jinglescode.github.io/time-series-forecasting-tensorflowjs/ - */ const MODULE_NAME = 'Time Series Forcasting Tensor Flow JS Learning Algorithm' let thisObject = { updateChart: updateChart, diff --git a/TaskServer/MultiProject.js b/TaskServer/MultiProject.js index e12a68d62..834cb9400 100644 --- a/TaskServer/MultiProject.js +++ b/TaskServer/MultiProject.js @@ -30,7 +30,6 @@ exports.newMultiProject = function () { projectInstance.taskModules = {} projectInstance.processModules = {} projectInstance.botModules = {} - projectInstance.algorithmModules = {} /* Set up Utilities of this Project */ if (projectDefinition.TS.utilities !== undefined) { @@ -100,17 +99,6 @@ exports.newMultiProject = function () { projectInstance.botModules[botModuleDefinition.propertyName] = requiredObject } } - - /* Set up Algorithm Modules for this Project */ - if (projectDefinition.TS.algorithmModules !== undefined) { - for (let j = 0; j < projectDefinition.TS.algorithmModules.length; j++) { - let algorithmModuleDefinition = projectDefinition.TS.algorithmModules[j] - let path = global.env.PATH_TO_PROJECTS_REQUIRED + '/' + projectDefinition.name + '/' + 'TS' + '/' + 'Bot-Modules' + '/' + algorithmModuleDefinition.folderName + '/' + algorithmModuleDefinition.fileName - - let requiredObject = require(path) - projectInstance.algorithmModules[algorithmModuleDefinition.propertyName] = requiredObject - } - } } TS.projects.superalgos.globals.taskConstants.PROJECTS_SCHEMA = PROJECTS_SCHEMA