diff --git a/.gitignore b/.gitignore index d7398ce0f..ce9eca3d9 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ debug.log .DS_Store *.db Projects/Superalgos/Icons/Thumbs.db -Projects/Superalgos/Icons/Thumbs.db -Projects/Superalgos/Icons/Thumbs.db +*.bat +*.exe + 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/Superalgos/UI/Function-Libraries/LearningSessionFunctions.js b/Projects/Superalgos/UI/Function-Libraries/LearningSessionFunctions.js index 51e5303e5..f333e421b 100644 --- a/Projects/Superalgos/UI/Function-Libraries/LearningSessionFunctions.js +++ b/Projects/Superalgos/UI/Function-Libraries/LearningSessionFunctions.js @@ -68,7 +68,8 @@ function newSuperalgosFunctionLibraryLearningSessionFunctions() { 'Environment Flags->Debug Mode->Production Mode->' + 'Supervised Learning->Unsupervised Learning->Self Learning->Reinforcement Learning->' + 'Artificial Neural Network->Model->' + - 'Optimizer->Loss Function->Metrics->' + + 'Compile->Optimizer->Loss Function->Metrics->' + + 'Fit Dataset->Verbose->Epochs->Callbacks->' + 'Layers API->Code API->' + 'Secuential Model->Functional Model->' + 'Input Layer->Secuential Layer->Output Layer->'+ diff --git a/Projects/TensorFlow/Schemas/AppSchema.json b/Projects/TensorFlow/Schemas/AppSchema.json index 6539e5453..c10cfac5d 100644 --- a/Projects/TensorFlow/Schemas/AppSchema.json +++ b/Projects/TensorFlow/Schemas/AppSchema.json @@ -354,25 +354,17 @@ { "action": "Add UI Object", "disableIfPropertyIsDefined": true, - "propertyToCheckFor": "optimizer", - "label": "Add Optimizer", - "relatedUiObject": "Optimizer", + "propertyToCheckFor": "compile", + "label": "Add Compile", + "relatedUiObject": "Compile", "actionFunction": "payload.executeAction" }, { "action": "Add UI Object", "disableIfPropertyIsDefined": true, - "propertyToCheckFor": "lossFunction", - "label": "Add Loss Function", - "relatedUiObject": "Loss Function", - "actionFunction": "payload.executeAction" - }, - { - "action": "Add UI Object", - "disableIfPropertyIsDefined": true, - "propertyToCheckFor": "metrics", - "label": "Add Metrics", - "relatedUiObject": "Metrics", + "propertyToCheckFor": "fitDataset", + "label": "Add Fit Dataset", + "relatedUiObject": "Fit Dataset", "actionFunction": "payload.executeAction" }, { @@ -408,6 +400,63 @@ "type": "node", "childType": "Core API" }, + { + "name": "compile", + "type": "node", + "childType": "Compile" + }, + { + "name": "fitDataset", + "type": "node", + "childType": "Fit Dataset" + } + ], + "icon": "tensorflow" + }, + { + "type": "Compile", + "menuItems": [ + { + "action": "Add UI Object", + "disableIfPropertyIsDefined": true, + "propertyToCheckFor": "optimizer", + "label": "Add Optimizer", + "relatedUiObject": "Optimizer", + "actionFunction": "payload.executeAction" + }, + { + "action": "Add UI Object", + "disableIfPropertyIsDefined": true, + "propertyToCheckFor": "lossFunction", + "label": "Add Loss Function", + "relatedUiObject": "Loss Function", + "actionFunction": "payload.executeAction" + }, + { + "action": "Add UI Object", + "disableIfPropertyIsDefined": true, + "propertyToCheckFor": "metrics", + "label": "Add Metrics", + "relatedUiObject": "Metrics", + "actionFunction": "payload.executeAction" + }, + { + "action": "Delete UI Object", + "askConfirmation": true, + "confirmationLabel": "Confirm to Delete", + "label": "Delete", + "iconPathOn": "delete-entity", + "iconPathOff": "delete-entity", + "actionFunction": "payload.executeAction" + } + ], + "addLeftIcons": true, + "level": 3, + "attachingRules": { + "compatibleTypes": "->Model->" + }, + "propertyNameAtParent": "model", + "childrenNodesProperties": [ { "name": "optimizer", "type": "node", @@ -426,6 +475,173 @@ ], "icon": "tensorflow" }, + { + "type": "Fit Dataset", + "menuItems": [ + { + "action": "Add UI Object", + "disableIfPropertyIsDefined": true, + "propertyToCheckFor": "verbose", + "label": "Add Verbose", + "relatedUiObject": "Verbose", + "actionFunction": "payload.executeAction" + }, + { + "action": "Add UI Object", + "disableIfPropertyIsDefined": true, + "propertyToCheckFor": "epochs", + "label": "Add Epochs", + "relatedUiObject": "Epochs", + "actionFunction": "payload.executeAction" + }, + { + "action": "Add UI Object", + "disableIfPropertyIsDefined": true, + "propertyToCheckFor": "callbacks", + "label": "Add Callbacks", + "relatedUiObject": "Callbacks", + "actionFunction": "payload.executeAction" + }, + { + "action": "Delete UI Object", + "askConfirmation": true, + "confirmationLabel": "Confirm to Delete", + "label": "Delete", + "iconPathOn": "delete-entity", + "iconPathOff": "delete-entity", + "actionFunction": "payload.executeAction" + } + ], + "addLeftIcons": true, + "level": 3, + "attachingRules": { + "compatibleTypes": "->Model->" + }, + "propertyNameAtParent": "model", + "childrenNodesProperties": [ + { + "name": "verbose", + "type": "node", + "childType": "Verbose" + }, + { + "name": "epochs", + "type": "node", + "childType": "Epochs" + }, + { + "name": "callbacks", + "type": "node", + "childType": "Callbacks" + } + ], + "icon": "tensorflow" + }, + { + "type": "Verbose", + "menuItems": [ + { + "action": "Configure", + "label": "Configure", + "iconPathOn": "configuration", + "iconPathOff": "configuration", + "actionFunction": "uiObject.configEditor.activate" + }, + { + "action": "Delete UI Object", + "askConfirmation": true, + "confirmationLabel": "Confirm to Delete", + "label": "Delete", + "iconPathOn": "delete-entity", + "iconPathOff": "delete-entity", + "actionFunction": "payload.executeAction" + } + ], + "editors": { + "config": true + }, + "initialValues": { + "config": "{ \n \"value\": 1\n}" + }, + "addLeftIcons": true, + "level": 3, + "attachingRules": { + "compatibleTypes": "->Fit Dataset->" + }, + "propertyNameAtParent": "verbose", + "childrenNodesProperties": [], + "icon": "tensorflow" + }, + { + "type": "Epochs", + "menuItems": [ + { + "action": "Configure", + "label": "Configure", + "iconPathOn": "configuration", + "iconPathOff": "configuration", + "actionFunction": "uiObject.configEditor.activate" + }, + { + "action": "Delete UI Object", + "askConfirmation": true, + "confirmationLabel": "Confirm to Delete", + "label": "Delete", + "iconPathOn": "delete-entity", + "iconPathOff": "delete-entity", + "actionFunction": "payload.executeAction" + } + ], + "editors": { + "config": true + }, + "initialValues": { + "config": "{ \n \"value\": 1\n}" + }, + "addLeftIcons": true, + "level": 3, + "attachingRules": { + "compatibleTypes": "->Fit Dataset->" + }, + "propertyNameAtParent": "epochs", + "childrenNodesProperties": [], + "icon": "tensorflow" + }, + { + "type": "Callbacks", + "menuItems": [ + { + "action": "Configure", + "label": "Configure", + "iconPathOn": "configuration", + "iconPathOff": "configuration", + "actionFunction": "uiObject.configEditor.activate" + }, + { + "action": "Delete UI Object", + "askConfirmation": true, + "confirmationLabel": "Confirm to Delete", + "label": "Delete", + "iconPathOn": "delete-entity", + "iconPathOff": "delete-entity", + "actionFunction": "payload.executeAction" + } + ], + "editors": { + "config": true + }, + "initialValues": { + "config": "{ \n \"value\": \"\"\n}" + }, + "addLeftIcons": true, + "level": 3, + "attachingRules": { + "compatibleTypes": "->Fit Dataset->" + }, + "propertyNameAtParent": "callbacks", + "childrenNodesProperties": [], + "icon": "tensorflow" + }, { "type": "Optimizer", "menuItems": [ @@ -455,7 +671,7 @@ "addLeftIcons": true, "level": 3, "attachingRules": { - "compatibleTypes": "->Model->" + "compatibleTypes": "->Compile->" }, "propertyNameAtParent": "optimizer", "childrenNodesProperties": [], @@ -490,7 +706,7 @@ "addLeftIcons": true, "level": 3, "attachingRules": { - "compatibleTypes": "->Model->" + "compatibleTypes": "->Compile->" }, "propertyNameAtParent": "lossFunction", "childrenNodesProperties": [], @@ -520,12 +736,12 @@ "config": true }, "initialValues": { - "config": "{ \n \"value\": [\"accuracy\"]\n}" + "config": "{ \n \"value\": [\"acc\"]\n}" }, "addLeftIcons": true, "level": 3, "attachingRules": { - "compatibleTypes": "->Model->" + "compatibleTypes": "->Compile->" }, "propertyNameAtParent": "metrics", "childrenNodesProperties": [], 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..04e7e7e3a 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) { @@ -227,8 +229,20 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { Check if this is the input layer. */ if (secuentialModel.inputLayer.referenceParent.id === layerNode.id) { + /* + If there is a explicitly defined Input Shape, then we will take it, + otherwise, we will count the amount of features declared. + */ if (secuentialModel.inputLayer.inputShape !== undefined) { - argsObject.inputShape = secuentialModel.inputLayer.inputShape.config.value + if (argsObject.inputShape = secuentialModel.inputLayer.inputShape !== undefined) { + if (argsObject.inputShape = secuentialModel.inputLayer.inputShape.config.value !== undefined) { + argsObject.inputShape = secuentialModel.inputLayer.inputShape.config.value + } + } + } + if (argsObject.inputShape === undefined) { + argsObject.inputShape = [] + argsObject.inputShape.push(secuentialModel.inputLayer.inputFeatures.dataFeatures.length) } } @@ -240,37 +254,43 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { } function compileModel() { - if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.optimizer === undefined) { + if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile === undefined) { //TODO return } - if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.optimizer.config.value === undefined) { + if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.optimizer === undefined) { //TODO return } - if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.lossFunction === undefined) { + if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.optimizer.config.value === undefined) { //TODO return } - if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.lossFunction.config.value === undefined) { + if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.lossFunction === undefined) { //TODO return } - if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.metrics === undefined) { + if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.compile.lossFunction.config.value === undefined) { //TODO return } - if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.metrics.config.value === undefined) { + 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.optimizer.config.value, - loss: learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.lossFunction.config.value, - metrics: [learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.metrics.config.value] + 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() } } @@ -287,9 +307,6 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { tensorFlowAPI = undefined tensorFlowModel = undefined tensorFlowData = undefined - - features = [] - labels = [] } function updateChart(pChart, pExchange, pMarket) { @@ -309,9 +326,11 @@ 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,24 +370,45 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { tensorFlowData = require("@tensorflow/tfjs-data") - let dataset = tensorFlowData.array([features, labels]) + function* featuresGenerator() { + console.log('Features: ' + features) + yield features + } - tensorFlowModel.fitDataset(dataset, { epochs: 5 }).then(info => { - console.log('Accuracy', info.history.acc); + function* labelsGenerator() { + console.log('Labels: ' + labels) + yield labels + } - /* - if all is good, return this... - */ - callbackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE) + const xs = tensorFlowData.generator(featuresGenerator) + const ys = tensorFlowData.generator(labelsGenerator) + const ds = tensorFlowData.zip({ xs, ys }).shuffle(1).batch(1) - }); + let verbose = 0 + let ecpochs = 1 + if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset !== undefined) { + if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.verbose !== undefined) { + if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.verbose.config.value !== undefined) { + verbose = learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.verbose.config.value + } + } + } + if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset !== undefined) { + if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.epochs !== undefined) { + if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.epochs.config.value !== undefined) { + ecpochs = learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.epochs.config.value + } + } + } - /* - if something is bad, return this... - */ - //callbackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE) + await tensorFlowModel.fitDataset(ds, { + verbose: verbose, + epochs: ecpochs + }) + + tensorFlowModel.summary() }