Model being trained, loaded and saved to disk.
This commit is contained in:
1 parent
9cd43d5ee5
commit
7d5a997272
4 files changed
+94
-42
No files matched your search
+38
@@ -40,6 +40,44 @@ exports.newSuperalgosBotModulesLearningSimulation = function (processIndex) {
|
||||
let learningSystemModuleObject = TS.projects.superalgos.botModules.learningSystem.newSuperalgosBotModulesLearningSystem(processIndex)
|
||||
learningSystemModuleObject.initialize()
|
||||
|
||||
/*
|
||||
Here we will figure out if we need to load the model from disk, or we will just
|
||||
start a new one.
|
||||
*/
|
||||
if (learningEngine.learningCurrent.learningEpisode.headOfTheMarket.value === true) {
|
||||
/*
|
||||
At the head of the market we always load the model from disk.
|
||||
*/
|
||||
await learningSystemModuleObject.loadModel()
|
||||
|
||||
} else {
|
||||
if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_PROCESSING_DAILY_FILES === true) {
|
||||
/*
|
||||
For Daily Files, we are going to load the model from disk at the first execution
|
||||
(first day) only if the user used the Session Resume option. We will load it from
|
||||
disk at every subsequent day, so as to continue with the training from the previous
|
||||
days.
|
||||
*/
|
||||
if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).IS_SESSION_FIRST_LOOP === true) {
|
||||
if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).IS_SESSION_RESUMING === true) {
|
||||
await learningSystemModuleObject.loadModel()
|
||||
}
|
||||
} else {
|
||||
await learningSystemModuleObject.loadModel()
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
Form Market Files, we are only going to load the model from this and continue the
|
||||
training it already has when the user resumes the training session. If the user
|
||||
runs the training session, we will not load from disk, but create a new empty model
|
||||
instead.
|
||||
*/
|
||||
if (TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).IS_SESSION_RESUMING === true) {
|
||||
await learningSystemModuleObject.loadModel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let learningEpisodeModuleObject = TS.projects.superalgos.botModules.learningEpisode.newSuperalgosBotModulesLearningEpisode(processIndex)
|
||||
learningEpisodeModuleObject.initialize()
|
||||
|
||||
|
||||
+5
@@ -5,6 +5,7 @@ exports.newSuperalgosBotModulesLearningSystem = function (processIndex) {
|
||||
*/
|
||||
const MODULE_NAME = 'Learning System'
|
||||
let thisObject = {
|
||||
loadModel: loadModel,
|
||||
saveModel: saveModel,
|
||||
mantain: mantain,
|
||||
reset: reset,
|
||||
@@ -184,6 +185,10 @@ exports.newSuperalgosBotModulesLearningSystem = function (processIndex) {
|
||||
sessionParameters = undefined
|
||||
}
|
||||
|
||||
async function loadModel() {
|
||||
await machineLearningLibraryModuleObject.loadModel()
|
||||
}
|
||||
|
||||
async function saveModel() {
|
||||
await machineLearningLibraryModuleObject.saveModel()
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"type":"Workspace","name":"Machine-Learning-Demo","rootNodes":[{"type":"Network","name":"My Network","project":"Superalgos","networkNodes":[{"type":"Network Node","name":"My Computer","config":"{ \n\"host\": \"localhost\", \n\"webPort\": \"34248\", \n\"webSocketsPort\": \"18041\"\n}","project":"Superalgos","dataTasks":{"type":"Data Tasks","name":"New Data Tasks","project":"Superalgos","projectDataTasks":[{"type":"Project Data Tasks","name":"Superalgos","project":"Superalgos","exchangeDataTasks":[{"type":"Exchange Data Tasks","name":"Binance","project":"Superalgos","marketDataTasks":[{"type":"Market Data Tasks","name":"Binance BTC/USDT","project":"Superalgos","dataMineTasks":[{"type":"Data Mine Tasks","name":"Masters","project":"Superalgos","taskManagers":[{"type":"Task Manager","name":"Masters","project":"Superalgos","tasks":[{"type":"Task","name":"Exchange Raw Data","project":"Superalgos","bot":{"type":"Sensor Bot Instance","name":"Exchange Raw Data","config":"{\n \"startDate\": \"2021-01-01\"\n}","project":"Superalgos","processes":[{"type":"Sensor Process Instance","name":"Exchange Raw Data Historic-OHLCVs","project":"Superalgos","id":"31e87840-fc8a-4305-a97d-3a78b8e4be61","savedPayload":{"position":{"x":23464.726581780902,"y":29681.25609376178},"targetPosition":{"x":23756.270052277963,"y":29610.528413108954},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"referenceParent":{"type":"Process Definition","name":"Historic-OHLCVs","id":"5eb11d6a-022e-4f60-97c4-d6cf90b249dc"}}}],"id":"ddab2649-221f-40c4-8b8e-b3cbceca0c4b","savedPayload":{"position":{"x":23756.270052277963,"y":29610.528413108954},"targetPosition":{"x":24047.813522775024,"y":29539.800732456126},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"1bca451f-f059-4dc2-87cb-ba2bb1c16ef4","savedPayload":{"position":{"x":24047.813522775024,"y":29539.800732456126},"targetPosition":{"x":24339.356993272086,"y":29469.073051803298},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Task","name":"Webhooks","project":"Superalgos","bot":{"type":"Sensor Bot Instance","name":"Webhooks","config":"{ \n\"startDate\": \"2020-01-01\"\n}","project":"Superalgos","processes":[{"type":"Sensor Process Instance","name":"Webhooks Check-Webhook","project":"Superalgos","id":"4595558a-d0ba-49b1-9c81-67696f23261c","savedPayload":{"position":{"x":23440.376388007382,"y":29426.249327561927},"targetPosition":{"x":23740.036589762283,"y":29440.52390230905},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"referenceParent":{"type":"Process Definition","name":"Check-Webhook","id":"69f37820-ab16-4e19-bfd8-386dd6e249a3"}}}],"id":"a7978877-bdef-4e69-a97d-af0560ef219e","savedPayload":{"position":{"x":23740.036589762283,"y":29440.52390230905},"targetPosition":{"x":24039.696791517184,"y":29454.798477056174},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"bf34c6df-d1ac-4f7c-8a6c-7ed9b6de2e00","savedPayload":{"position":{"x":24039.696791517184,"y":29454.798477056174},"targetPosition":{"x":24339.356993272086,"y":29469.073051803298},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Task","name":"Candles Volumes","project":"Superalgos","bot":{"type":"Indicator Bot Instance","name":"Candles Volumes","project":"Superalgos","processes":[{"type":"Indicator Process Instance","name":"Candles Volumes Multi-Period-Market","project":"Superalgos","id":"7cdc33e0-c56b-43ce-95f5-db03a171f021","savedPayload":{"position":{"x":23473.12086766021,"y":29251.430518853074},"targetPosition":{"x":23772.356502043287,"y":29272.832273812845},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"referenceParent":{"type":"Process Definition","name":"Multi-Period-Market","id":"9f683143-a33f-42c1-9fa8-c601f01ee4e1"}}},{"type":"Indicator Process Instance","name":"Candles Volumes Multi-Period-Daily","project":"Superalgos","id":"4da5ecc7-48e6-4283-8a2f-512528a28fe4","savedPayload":{"position":{"x":23523.911718429878,"y":29104.679993140577},"targetPosition":{"x":23772.356502043287,"y":29272.832273812845},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"referenceParent":{"type":"Process DefiniLine truncated
|
||||
{"type":"Workspace","name":"Machine-Learning-Demo","rootNodes":[{"type":"Network","name":"My Network","project":"Superalgos","networkNodes":[{"type":"Network Node","name":"My Computer","config":"{ \n\"host\": \"localhost\", \n\"webPort\": \"34248\", \n\"webSocketsPort\": \"18041\"\n}","project":"Superalgos","dataTasks":{"type":"Data Tasks","name":"New Data Tasks","project":"Superalgos","projectDataTasks":[{"type":"Project Data Tasks","name":"Superalgos","project":"Superalgos","exchangeDataTasks":[{"type":"Exchange Data Tasks","name":"Binance","project":"Superalgos","marketDataTasks":[{"type":"Market Data Tasks","name":"Binance BTC/USDT","project":"Superalgos","dataMineTasks":[{"type":"Data Mine Tasks","name":"Masters","project":"Superalgos","taskManagers":[{"type":"Task Manager","name":"Masters","project":"Superalgos","tasks":[{"type":"Task","name":"Exchange Raw Data","project":"Superalgos","bot":{"type":"Sensor Bot Instance","name":"Exchange Raw Data","config":"{\n \"startDate\": \"2021-01-01\"\n}","project":"Superalgos","processes":[{"type":"Sensor Process Instance","name":"Exchange Raw Data Historic-OHLCVs","project":"Superalgos","id":"31e87840-fc8a-4305-a97d-3a78b8e4be61","savedPayload":{"position":{"x":23464.726581780902,"y":29681.25609376178},"targetPosition":{"x":23756.270052277963,"y":29610.528413108954},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"referenceParent":{"type":"Process Definition","name":"Historic-OHLCVs","id":"5eb11d6a-022e-4f60-97c4-d6cf90b249dc"}}}],"id":"ddab2649-221f-40c4-8b8e-b3cbceca0c4b","savedPayload":{"position":{"x":23756.270052277963,"y":29610.528413108954},"targetPosition":{"x":24047.813522775024,"y":29539.800732456126},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"1bca451f-f059-4dc2-87cb-ba2bb1c16ef4","savedPayload":{"position":{"x":24047.813522775024,"y":29539.800732456126},"targetPosition":{"x":24339.356993272086,"y":29469.073051803298},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Task","name":"Webhooks","project":"Superalgos","bot":{"type":"Sensor Bot Instance","name":"Webhooks","config":"{ \n\"startDate\": \"2020-01-01\"\n}","project":"Superalgos","processes":[{"type":"Sensor Process Instance","name":"Webhooks Check-Webhook","project":"Superalgos","id":"4595558a-d0ba-49b1-9c81-67696f23261c","savedPayload":{"position":{"x":23440.376388007382,"y":29426.249327561927},"targetPosition":{"x":23740.036589762283,"y":29440.52390230905},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"referenceParent":{"type":"Process Definition","name":"Check-Webhook","id":"69f37820-ab16-4e19-bfd8-386dd6e249a3"}}}],"id":"a7978877-bdef-4e69-a97d-af0560ef219e","savedPayload":{"position":{"x":23740.036589762283,"y":29440.52390230905},"targetPosition":{"x":24039.696791517184,"y":29454.798477056174},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},"id":"bf34c6df-d1ac-4f7c-8a6c-7ed9b6de2e00","savedPayload":{"position":{"x":24039.696791517184,"y":29454.798477056174},"targetPosition":{"x":24339.356993272086,"y":29469.073051803298},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Task","name":"Candles Volumes","project":"Superalgos","bot":{"type":"Indicator Bot Instance","name":"Candles Volumes","project":"Superalgos","processes":[{"type":"Indicator Process Instance","name":"Candles Volumes Multi-Period-Market","project":"Superalgos","id":"7cdc33e0-c56b-43ce-95f5-db03a171f021","savedPayload":{"position":{"x":23473.12086766021,"y":29251.430518853074},"targetPosition":{"x":23772.356502043287,"y":29272.832273812845},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"referenceParent":{"type":"Process Definition","name":"Multi-Period-Market","id":"9f683143-a33f-42c1-9fa8-c601f01ee4e1"}}},{"type":"Indicator Process Instance","name":"Candles Volumes Multi-Period-Daily","project":"Superalgos","id":"4da5ecc7-48e6-4283-8a2f-512528a28fe4","savedPayload":{"position":{"x":23523.911718429878,"y":29104.679993140577},"targetPosition":{"x":23772.356502043287,"y":29272.832273812845},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":3,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false},"referenceParent":{"type":"Process DefiniLine truncated
|
||||
+50
-41
@@ -2,6 +2,7 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) {
|
||||
|
||||
const MODULE_NAME = 'Time Series Forcasting Tensor Flow JS Learning Algorithm'
|
||||
let thisObject = {
|
||||
loadModel: loadModel,
|
||||
saveModel: saveModel,
|
||||
updateChart: updateChart,
|
||||
mantain: mantain,
|
||||
@@ -255,46 +256,46 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function compileModel() {
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile === undefined) {
|
||||
//TODO
|
||||
return
|
||||
}
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.optimizer === undefined) {
|
||||
//TODO
|
||||
return
|
||||
}
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.optimizer.config.value === undefined) {
|
||||
//TODO
|
||||
return
|
||||
}
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.lossFunction === undefined) {
|
||||
//TODO
|
||||
return
|
||||
}
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.lossFunction.config.value === undefined) {
|
||||
//TODO
|
||||
return
|
||||
}
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.metrics === undefined) {
|
||||
//TODO
|
||||
return
|
||||
}
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.metrics.config.value === undefined) {
|
||||
//TODO
|
||||
return
|
||||
}
|
||||
let compileArgs = {
|
||||
optimizer: learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.optimizer.config.value,
|
||||
loss: learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.lossFunction.config.value /*,
|
||||
metrics: [learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.metrics.config.value]*/
|
||||
}
|
||||
|
||||
tensorFlowModel.compile(compileArgs)
|
||||
|
||||
tensorFlowModel.summary()
|
||||
function compileModel() {
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile === undefined) {
|
||||
//TODO
|
||||
return
|
||||
}
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.optimizer === undefined) {
|
||||
//TODO
|
||||
return
|
||||
}
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.optimizer.config.value === undefined) {
|
||||
//TODO
|
||||
return
|
||||
}
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.lossFunction === undefined) {
|
||||
//TODO
|
||||
return
|
||||
}
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.lossFunction.config.value === undefined) {
|
||||
//TODO
|
||||
return
|
||||
}
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.metrics === undefined) {
|
||||
//TODO
|
||||
return
|
||||
}
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.metrics.config.value === undefined) {
|
||||
//TODO
|
||||
return
|
||||
}
|
||||
let compileArgs = {
|
||||
optimizer: learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.optimizer.config.value,
|
||||
loss: learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.lossFunction.config.value /*,
|
||||
metrics: [learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.metrics.config.value]*/
|
||||
}
|
||||
|
||||
tensorFlowModel.compile(compileArgs)
|
||||
|
||||
tensorFlowModel.summary()
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
@@ -312,16 +313,24 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) {
|
||||
tensorFlowData = undefined
|
||||
}
|
||||
|
||||
async function saveModel() {
|
||||
async function loadModel() {
|
||||
tensorFlowModel = await tensorFlowAPI.loadLayersModel('file://' + getModelPath() + '/model.json')
|
||||
compileModel()
|
||||
}
|
||||
|
||||
async function saveModel() {
|
||||
await tensorFlowModel.save('file://' + getModelPath())
|
||||
}
|
||||
|
||||
function getModelPath() {
|
||||
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'
|
||||
TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_FOLDER_NAME
|
||||
|
||||
await tensorFlowModel.save('file://' + filePath + '/' + fileName)
|
||||
return filePath + '/' + fileName
|
||||
}
|
||||
|
||||
function updateChart(pChart, pExchange, pMarket) {
|
||||
|
||||
Reference in new issue
Block a user