Execution Environment Implemented

This commit is contained in:
Luis Fernando Molina committed 2021-02-16 14:53:16 +01:00
1 parent 88e07e40de
commit e58bc4d916
3 files changed
+63 -3

No files matched your search

@@ -26,6 +26,8 @@ exports.newSuperalgosBotModulesLearningSystem = function (processIndex) {
let sessionParameters
let dynamicIndicators
let machineLearningLibraryModuleObject
return thisObject
function initialize() {
@@ -103,7 +105,6 @@ exports.newSuperalgosBotModulesLearningSystem = function (processIndex) {
*/
let machineLearningLibrary = learningSystem.machineLearningLibrary
let machineLearningLibraryModuleObject
if (machineLearningLibrary === undefined) {
// TODO
@@ -63,7 +63,7 @@ function newSuperalgosFunctionLibraryLearningSessionFunctions() {
let lightingPath = '' +
'Learning System->' +
'TensorFlow Library->' +
'Execution Environmnet->Supervised Learning->Unsupervised Learning->Self Learning->Reinforcement Learning->' +
'Execution Environment->Supervised Learning->Unsupervised Learning->Self Learning->Reinforcement Learning->' +
'WebGL Backend->NodeJS Backend->WASM Backend->CPU Backend->' +
'Environment Flags->Debug Mode->Production Mode->' +
'Supervised Learning->Unsupervised Learning->Self Learning->Reinforcement Learning->' +
@@ -22,6 +22,8 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) {
let exchange
let market
let tensorFlowBackend
return thisObject
function initialize(callbackFunction) {
@@ -29,7 +31,64 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) {
learningEngine = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE.learningEngine
sessionParameters = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.learningParameters
setupBackend()
setupEnvironmentFlags()
callbackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE)
function setupBackend() {
/*
Setup the default backend.
*/
tensorFlowBackend = require("@tensorflow/tfjs-node")
if (
learningSystem.machineLearningLibrary.executionEnvironment !== undefined &&
learningSystem.machineLearningLibrary.executionEnvironment.backend !== undefined
) {
/*
Replace the backend for the one defined at the UI.
*/
switch (learningSystem.machineLearningLibrary.executionEnvironment.backend.config.codeName) {
case 'node': {
// This is already the default.
break
}
case 'webgl': {
tensorFlowBackend = require("@tensorflow/tfjs-backend-webgl")
break
}
case 'wasm': {
tensorFlowBackend = require("@tensorflow/tfjs-backend-wasm")
break
}
case 'cpu': {
tensorFlowBackend = require("@tensorflow/tfjs-backend-cpu")
break
}
}
}
}
function setupEnvironmentFlags() {
if (
learningSystem.machineLearningLibrary.executionEnvironment !== undefined &&
learningSystem.machineLearningLibrary.executionEnvironment.environmentFlags !== undefined &&
learningSystem.machineLearningLibrary.executionEnvironment.environmentFlags.mode
) {
switch (learningSystem.machineLearningLibrary.executionEnvironment.environmentFlags.mode.type) {
case 'Debug Mode': {
tensorFlowBackend.enableDebugMode()
break
}
case 'Debug Mode': {
tensorFlowBackend.enableProdMode()
break
}
}
}
}
}
function finalize() {
@@ -53,7 +112,7 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) {
}
function mantain() {
}
function reset() {