From c746191b225f3e59f4b7b0cee6a01c2e5bf00271 Mon Sep 17 00:00:00 2001 From: Danijel Anđelković Date: Wed, 4 May 2022 18:17:28 +0200 Subject: Dodao dodavanje modela i popravio klasu model na beku. --- backend/api/api/Controllers/ModelController.cs | 3 +++ backend/api/api/Models/Model.cs | 14 ++++++++++++-- backend/api/api/Services/FillAnEmptyDb.cs | 6 ------ 3 files changed, 15 insertions(+), 8 deletions(-) (limited to 'backend') diff --git a/backend/api/api/Controllers/ModelController.cs b/backend/api/api/Controllers/ModelController.cs index fb30a7a2..d68e98e2 100644 --- a/backend/api/api/Controllers/ModelController.cs +++ b/backend/api/api/Controllers/ModelController.cs @@ -187,8 +187,11 @@ namespace api.Controllers /*if (_modelService.CheckHyperparameters(1, model.hiddenLayerNeurons, model.hiddenLayers, model.outputNeurons) == false) return BadRequest("Bad parameters!");*/ + model.uploaderId = getUserId(); + var existingModel = _modelService.GetOneModel(model.uploaderId, model.name); + if (existingModel != null && !overwrite) return NotFound($"Model with name = {model.name} exisits"); else diff --git a/backend/api/api/Models/Model.cs b/backend/api/api/Models/Model.cs index f89c8e56..d8921713 100644 --- a/backend/api/api/Models/Model.cs +++ b/backend/api/api/Models/Model.cs @@ -26,12 +26,11 @@ namespace api.Models public string optimizer { get; set; } public string lossFunction { get; set; } //public int inputNeurons { get; set; } - public int hiddenLayerNeurons { get; set; } public int hiddenLayers { get; set; } public int batchSize { get; set; } // na izlazu je moguce da bude vise neurona (klasifikacioni problem sa vise od 2 klase) public int outputNeurons { get; set; } - public string[] hiddenLayerActivationFunctions { get; set; } + public Layer[] layers { get; set; } public string outputLayerActivationFunction { get; set; } public string[] metrics { get; set; } @@ -42,4 +41,15 @@ namespace api.Models public bool randomTestSet { get; set; } public float randomTestSetDistribution { get; set; } } + + public class Layer + { + public int layerNumber { get; set; } + public string activationFunction { get; set; } + public int neurons { get; set; } + public string regularisation { get; set; } + public float regularisationRate { get; set; } + } } + + diff --git a/backend/api/api/Services/FillAnEmptyDb.cs b/backend/api/api/Services/FillAnEmptyDb.cs index d1208c9c..1b6b8bbf 100644 --- a/backend/api/api/Services/FillAnEmptyDb.cs +++ b/backend/api/api/Services/FillAnEmptyDb.cs @@ -98,11 +98,9 @@ namespace api.Services model.type = "binarni-klasifikacioni"; model.optimizer = "Adam"; model.lossFunction = "mean_squared_error"; - model.hiddenLayerNeurons = 3; model.hiddenLayers = 5; model.batchSize = 8; model.outputNeurons = 0; - model.hiddenLayerActivationFunctions = new string[] { "relu", "relu", "relu", "relu", "relu" }; model.outputLayerActivationFunction = "sigmoid"; model.metrics = new string[] { }; model.epochs = 5; @@ -212,11 +210,9 @@ namespace api.Services model.type = "regresioni"; model.optimizer = "Adam"; model.lossFunction = "mean_absolute_error"; - model.hiddenLayerNeurons = 2; model.hiddenLayers = 4; model.batchSize = 5; model.outputNeurons = 0; - model.hiddenLayerActivationFunctions = new string[] { "relu", "relu", "relu", "relu" }; model.outputLayerActivationFunction = "relu"; model.metrics = new string[] { }; model.epochs = 5; @@ -321,11 +317,9 @@ namespace api.Services model.type = "multi-klasifikacioni"; model.optimizer = "Adam"; model.lossFunction = "sparse_categorical_crossentropy"; - model.hiddenLayerNeurons = 3; model.hiddenLayers = 3; model.batchSize = 4; model.outputNeurons = 0; - model.hiddenLayerActivationFunctions = new string[] { "relu", "relu", "softmax" }; model.outputLayerActivationFunction = "softmax"; model.metrics = new string[] { }; model.epochs = 1; -- cgit v1.2.3