Some bugfixes and misc
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ComputedRef } from 'vue';
|
||||
import { computed } from 'vue';
|
||||
import type { ComputedRef } from 'vue';
|
||||
import type { Iteration } from '@/types/perceptron';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -13,7 +14,9 @@ const props = defineProps<{
|
||||
const allWeightPerIteration: ComputedRef<number[][]> = computed(() => {
|
||||
return props.iterations.map((iteration) => {
|
||||
// We flatten the weights
|
||||
return iteration.weights.flat(2);
|
||||
return iteration.weights
|
||||
.flat(2)
|
||||
.filter((weight): weight is number => weight !== null && Number.isFinite(weight));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -61,10 +64,10 @@ const rowBgDark = computed(() => {
|
||||
v-for="(weight, weightIndex) in allWeightPerIteration[index]"
|
||||
v-bind:key="weightIndex"
|
||||
>
|
||||
{{ weight.toFixed(2) }}
|
||||
{{ Number.isFinite(weight) ? weight.toFixed(2) : 'N/A' }}
|
||||
</td>
|
||||
</template>
|
||||
<td>{{ iteration.error.toFixed(2) }}</td>
|
||||
<td>{{ iteration.error === null ? 'N/A' : iteration.error.toFixed(2) }}</td>
|
||||
</tr>
|
||||
|
||||
<tr
|
||||
|
||||
@@ -28,6 +28,8 @@ const datasets = computed<ErrorDataset[]>(() => {
|
||||
const exampleCountPerEpoch: Record<number, number> = {};
|
||||
|
||||
props.iterations.forEach((iteration) => {
|
||||
const error = iteration.error ?? 0;
|
||||
|
||||
if (!epochErrorOnly.value) {
|
||||
const exampleLabel = `Exemple ${iteration.exampleIndex}`;
|
||||
let dataset = datasets.find((d) => d.label === exampleLabel);
|
||||
@@ -45,8 +47,8 @@ const datasets = computed<ErrorDataset[]>(() => {
|
||||
}
|
||||
dataset.data.push(
|
||||
props.isRegression
|
||||
? Math.abs(iteration.error)
|
||||
: iteration.error,
|
||||
? Math.abs(error)
|
||||
: error,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -55,7 +57,7 @@ const datasets = computed<ErrorDataset[]>(() => {
|
||||
// Epoch error
|
||||
epochAverageError[iteration.epoch] =
|
||||
(epochAverageError[iteration.epoch] || 0) +
|
||||
iteration.error ** 2 / 2;
|
||||
error ** 2 / 2;
|
||||
});
|
||||
|
||||
// Sort dataset by label (Exemple 0, Exemple 1, ...)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export type Iteration = {
|
||||
epoch: number;
|
||||
exampleIndex: number;
|
||||
weights: number[][][];
|
||||
error: number;
|
||||
weights: (number | null)[][][];
|
||||
error: number | null;
|
||||
};
|
||||
|
||||
export type Dataset = {
|
||||
|
||||
Reference in New Issue
Block a user