From 8a749faa9187263e206b347ec03c99a66113171a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jules=20Franc=CC=A7oise?= Date: Tue, 12 Oct 2021 13:55:53 +0200 Subject: [PATCH 1/6] MLP : throw an error if the dataset is empty --- src/components/mlp-classifier/mlp-classifier.component.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/mlp-classifier/mlp-classifier.component.ts b/src/components/mlp-classifier/mlp-classifier.component.ts index 59cee498..6f844ae4 100644 --- a/src/components/mlp-classifier/mlp-classifier.component.ts +++ b/src/components/mlp-classifier/mlp-classifier.component.ts @@ -20,6 +20,7 @@ import { import type { ServiceIterable } from '../../core/data-store/service-iterable'; import { Dataset, isDataset } from '../../core/dataset'; import { Catch, TrainingError } from '../../utils/error-handling'; +import { throwError } from '../../utils/error-handling'; interface TrainingData { training_x: Tensor2D; @@ -130,6 +131,13 @@ export class MLPClassifier extends TFJSBaseModel : (this.labels = Array.from(new Set(await dataset.map(({ y }) => y).toArray()))); const ds = isDataset(dataset) ? dataset.items() : dataset; this.$training.set({ status: 'start', epochs: this.parameters.epochs.value }); + if (this.labels.length === 0) { + throwError(new TrainingError('This dataset is empty or is missing labels')); + this.$training.set({ + status: 'error', + }); + return; + } setTimeout(async () => { const data = await dataSplit(ds, 0.75, this.labels); this.buildModel(data.training_x.shape[1], data.training_y.shape[1]); From d996756f357b3df41d089be801aca0618a9b0c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jules=20Franc=CC=A7oise?= Date: Tue, 12 Oct 2021 14:22:05 +0200 Subject: [PATCH 2/6] Various fixes in the training history component - bug with row selection and page changes - bug with training run indexing from the browser - bug with concurrent calls in training tracking --- .../training-history/training-history.component.ts | 10 +++++++++- .../training-history/training-history.view.svelte | 6 +++++- src/ui/components/Table.svelte | 9 +++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/components/training-history/training-history.component.ts b/src/components/training-history/training-history.component.ts index 55c95f0b..1d25d62d 100644 --- a/src/components/training-history/training-history.component.ts +++ b/src/components/training-history/training-history.component.ts @@ -1,6 +1,7 @@ import { Paginated, Service } from '@feathersjs/feathers'; import { logger, Model, Component, Stream, TrainingRun, TrainingStatus } from '../../core'; import { DataStore } from '../../core/data-store'; +import { preventConcurrentCalls } from '../../utils/asynchronicity'; import { noop } from '../../utils/misc'; import View from './training-history.view.svelte'; @@ -38,6 +39,8 @@ export class TrainingHistory extends Component { protected modelName: string; protected nextIndex: number; + private lock = Promise.resolve(); + constructor(public dataStore: DataStore, options: TrainingHistoryOptions = {}) { super(); this.options = { ...defaultOptions, ...options }; @@ -71,7 +74,7 @@ export class TrainingHistory extends Component { }) .then(({ data: foundRuns }) => { if (foundRuns.length > 0) { - return parseInt(foundRuns[0].name.split(`${name}-`)[1]) + 1; + return parseInt(foundRuns[0].name.split(`${basename}-`)[1]) + 1; } return 1; }) @@ -85,6 +88,7 @@ export class TrainingHistory extends Component { return this; } + @preventConcurrentCalls('lock') protected async trackTrainingStream(x: TrainingStatus): Promise { if (x.status === 'start') { this.crtRun = await this.runService.create({ @@ -119,6 +123,10 @@ export class TrainingHistory extends Component { }, ]), }); + } else if (x.status === 'error') { + this.runService.patch(this.crtRun.id, { + status: x.status, + }); } } diff --git a/src/components/training-history/training-history.view.svelte b/src/components/training-history/training-history.view.svelte index 690672e9..bae701e4 100644 --- a/src/components/training-history/training-history.view.svelte +++ b/src/components/training-history/training-history.view.svelte @@ -47,6 +47,10 @@ }, }); + provider.data.subscribe(() => { + selection.set([]); + }); + const columns: Column[] = [ { name: 'name', sortable: true }, { name: 'start', sortable: true, type: 'date' }, @@ -82,7 +86,7 @@ {provider} actions={[ ...actions.map((name) => (typeof name === 'string' ? { name } : name)), - { name: 'remove', confirm: true }, + { name: 'delete', confirm: true }, ]} bind:selection={$selection} bind:this={mainTable} diff --git a/src/ui/components/Table.svelte b/src/ui/components/Table.svelte index 19908a70..0a1be66a 100644 --- a/src/ui/components/Table.svelte +++ b/src/ui/components/Table.svelte @@ -1,5 +1,5 @@ @@ -250,11 +249,10 @@ .browser-class-body img { width: 60px; box-sizing: content-box; - @apply border-2 border-transparent rounded-md; + @apply border-solid border-2 border-transparent rounded-md; } .browser-class-body img.selected { - @apply border-teal-700; + @apply border-gray-600; } - From 4fbeed002c1cc74f8cf44a8ee8d36b7501e2d7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jules=20Franc=CC=A7oise?= Date: Tue, 12 Oct 2021 14:51:20 +0200 Subject: [PATCH 4/6] Fix Typescript warning --- src/components/training-history/training-history.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/training-history/training-history.component.ts b/src/components/training-history/training-history.component.ts index 1d25d62d..82346c06 100644 --- a/src/components/training-history/training-history.component.ts +++ b/src/components/training-history/training-history.component.ts @@ -44,6 +44,7 @@ export class TrainingHistory extends Component { constructor(public dataStore: DataStore, options: TrainingHistoryOptions = {}) { super(); this.options = { ...defaultOptions, ...options }; + this.lock = this.lock.then(noop); this.start(); this.ready = this.ready .then(() => this.dataStore.connect()) From 121f6e7a87d74dd173a992478eb3478d411371aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jules=20Franc=CC=A7oise?= Date: Tue, 12 Oct 2021 16:03:05 +0200 Subject: [PATCH 5/6] Fix table pagination --- src/ui/components/Select.svelte | 2 +- src/ui/components/TableFooter.svelte | 39 +++++++++++++++++---- src/ui/components/table-array-provider.ts | 1 + src/ui/components/table-service-provider.ts | 1 + 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/ui/components/Select.svelte b/src/ui/components/Select.svelte index a32de3e7..27a0537a 100644 --- a/src/ui/components/Select.svelte +++ b/src/ui/components/Select.svelte @@ -17,7 +17,7 @@ on:change={(e) => dispatch('change', e.target.value)} > {#if placeholder} - + {/if} {#each options as option} diff --git a/src/ui/components/TableFooter.svelte b/src/ui/components/TableFooter.svelte index 44aed183..8054c32e 100644 --- a/src/ui/components/TableFooter.svelte +++ b/src/ui/components/TableFooter.svelte @@ -1,23 +1,48 @@