aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/_elements/form-model/form-model.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/app/_elements/form-model/form-model.component.ts')
-rw-r--r--frontend/src/app/_elements/form-model/form-model.component.ts133
1 files changed, 41 insertions, 92 deletions
diff --git a/frontend/src/app/_elements/form-model/form-model.component.ts b/frontend/src/app/_elements/form-model/form-model.component.ts
index c3c73b3e..c29fd0bb 100644
--- a/frontend/src/app/_elements/form-model/form-model.component.ts
+++ b/frontend/src/app/_elements/form-model/form-model.component.ts
@@ -1,37 +1,36 @@
-import { Component, OnInit ,Input, ViewChild, Output, EventEmitter} from '@angular/core';
-import {FormControl, Validators} from '@angular/forms';
+import { Component, OnInit, Input, ViewChild, Output, EventEmitter, AfterViewInit } from '@angular/core';
+import { FormControl, Validators } from '@angular/forms';
import Shared from 'src/app/Shared';
import Experiment from 'src/app/_data/Experiment';
-import Model, {Layer, ActivationFunction, LossFunction,LearningRate, LossFunctionBinaryClassification, LossFunctionMultiClassification, LossFunctionRegression, Metrics, MetricsBinaryClassification, MetricsMultiClassification, MetricsRegression, NullValueOptions, Optimizer, ProblemType ,Regularisation,RegularisationRate} from 'src/app/_data/Model';
+import Model, { Layer, ActivationFunction, LossFunction, LearningRate, LossFunctionBinaryClassification, LossFunctionMultiClassification, LossFunctionRegression, Metrics, MetricsBinaryClassification, MetricsMultiClassification, MetricsRegression, NullValueOptions, Optimizer, ProblemType, Regularisation, RegularisationRate, BatchSize } from 'src/app/_data/Model';
import { GraphComponent } from '../graph/graph.component';
-import {FormGroupDirective, NgForm} from '@angular/forms';
-import {ErrorStateMatcher} from '@angular/material/core';
+import { FormGroupDirective, NgForm } from '@angular/forms';
+import { ErrorStateMatcher } from '@angular/material/core';
+
@Component({
selector: 'app-form-model',
templateUrl: './form-model.component.html',
styleUrls: ['./form-model.component.css']
})
-export class FormModelComponent implements OnInit {
+export class FormModelComponent implements AfterViewInit {
@ViewChild(GraphComponent) graph!: GraphComponent;
@Input() forExperiment?: Experiment;
@Output() selectedModelChangeEvent = new EventEmitter<Model>();
- constructor() {
- this.newModel.epochs=1;
- this.newModel.batchSize=1;
-}
-
- ngOnInit(): void {
+ constructor() { }
+
+ ngAfterViewInit(): void {
}
+
selectFormControl = new FormControl('', Validators.required);
nameFormControl = new FormControl('', [Validators.required, Validators.email]);
- selectTypeFormControl=new FormControl('', Validators.required);
- selectOptFormControl=new FormControl('', Validators.required);
- selectLFFormControl=new FormControl('', Validators.required);
- selectLRFormControl=new FormControl('', Validators.required);
- selectEpochFormControl=new FormControl('', Validators.required);
- selectAFFormControl=new FormControl('', Validators.required);
- selectBSFormControl=new FormControl('', Validators.required);
+ selectTypeFormControl = new FormControl('', Validators.required);
+ selectOptFormControl = new FormControl('', Validators.required);
+ selectLFFormControl = new FormControl('', Validators.required);
+ selectLRFormControl = new FormControl('', Validators.required);
+ selectEpochFormControl = new FormControl('', Validators.required);
+ selectAFFormControl = new FormControl('', Validators.required);
+ selectBSFormControl = new FormControl('', Validators.required);
selectActivationFormControl = new FormControl('', Validators.required);
selectRegularisationFormControl = new FormControl('', Validators.required);
selectRRateFormControl = new FormControl('', Validators.required);
@@ -43,92 +42,44 @@ export class FormModelComponent implements OnInit {
ProblemType = ProblemType;
ActivationFunction = ActivationFunction;
- RegularisationRate=RegularisationRate;
- Regularisation=Regularisation;
+ RegularisationRate = RegularisationRate;
+ Regularisation = Regularisation;
metrics: any = Metrics;
LossFunction = LossFunction;
Optimizer = Optimizer;
+ BatchSize = BatchSize;
Object = Object;
document = document;
shared = Shared;
- LearningRate=LearningRate;
- Layer=Layer;
-
+ LearningRate = LearningRate;
+ Layer = Layer;
+
term: string = "";
selectedMetrics = [];
lossFunction: any = LossFunction;
showMyModels: boolean = true;
-
- hiddenLayers=[];
-
-
-
updateGraph() {
+ console.log(this.newModel.layers);
this.graph.update();
}
- removeLayer(){
- if(this.newModel.hiddenLayers>1)
- {
- this.newModel.layers.splice(this.newModel.layers.length-1,1);
- this.newModel.hiddenLayers-=1;
+
+ removeLayer() {
+ if (this.newModel.hiddenLayers > 1) {
+ this.newModel.layers.splice(this.newModel.layers.length - 1, 1);
+ this.newModel.hiddenLayers -= 1;
this.updateGraph();
}
}
- addLayer(){
- if(this.newModel.hiddenLayers<12)
- {
+ addLayer() {
+ if (this.newModel.hiddenLayers < 128) {
this.newModel.layers.push(new Layer(this.newModel.layers.length));
- this.newModel.hiddenLayers+=1;
+ this.newModel.hiddenLayers += 1;
this.updateGraph();
}
-
- }
- removeBatch(){
- if(this.newModel.batchSize>1)
- {
- this.newModel.batchSize=this.newModel.batchSize/2;
- }
- else
- {
- this.newModel.batchSize=this.newModel.batchSize;
- }
-
- }
- addBatch(){
- if(this.newModel.batchSize<600)
- {
- this.newModel.batchSize=this.newModel.batchSize*2;
- }
- else
- {
- this.newModel.batchSize=this.newModel.batchSize;
-
- }
- }
- removeEpoch(){
- if(this.newModel.epochs>1)
- {
- this.newModel.epochs=this.newModel.epochs-1;
- }
- else
- {
- this.newModel.epochs=this.newModel.epochs;
- }
-
- }
- addEpoch(){
- if(this.newModel.epochs<100)
- {
- this.newModel.epochs=this.newModel.epochs+1;
- }
- else
- {
- this.newModel.epochs=this.newModel.epochs;
-
- }
+
}
/*
setNeurons()
@@ -140,18 +91,16 @@ export class FormModelComponent implements OnInit {
numSequence(n: number): Array<number> {
return Array(n);
}
-
- removeNeuron(index:number){
- if(this.newModel.layers[index].neurons>1)
- {
- this.newModel.layers[index].neurons-=1;
+
+ removeNeuron(index: number) {
+ if (this.newModel.layers[index].neurons > 1) {
+ this.newModel.layers[index].neurons -= 1;
this.updateGraph();
}
}
- addNeuron(index:number){
- if(this.newModel.layers[index].neurons<100)
- {
- this.newModel.layers[index].neurons+=1;
+ addNeuron(index: number) {
+ if (this.newModel.layers[index].neurons < 100) {
+ this.newModel.layers[index].neurons += 1;
this.updateGraph();
}
}