fit Dataset with params from UI

This commit is contained in:
Luis Fernando Molina committed 2021-02-20 10:10:57 +01:00
1 parent 6180f79c56
commit fd58d75dd2
3 files changed
+272 -32

No files matched your search

@@ -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->'+
+234 -18
View File
@@ -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": [],
@@ -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()