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/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/TensorFlowLibrary.js b/Projects/TensorFlow/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/TensorFlowLibrary.js index a7e16381a..eaf5494f1 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 @@ -242,34 +242,38 @@ 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) @@ -366,11 +370,30 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) { const xs = tensorFlowData.generator(featuresGenerator) const ys = tensorFlowData.generator(labelsGenerator) - const ds = tensorFlowData.zip({xs, ys}).shuffle(1).batch(1) - + 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 + } + } + } + await tensorFlowModel.fitDataset(ds, { - verbose: 1, - epochs: 10 + verbose: verbose, + epochs: ecpochs }) tensorFlowModel.summary()