Skip to content

Commit 59d8e43

Browse files
feat(ui): add a Reset button
1 parent 8f66c3d commit 59d8e43

1 file changed

Lines changed: 33 additions & 5 deletions

File tree

src/components/NN_comps/NN_specs.svelte

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
<script lang="ts">
22
// Implement Theme CHanger BY
33
// Changing the html tag data-theme attribute on each select menu click
4-
import { af_enum } from "./NN_classes.ts";
4+
import { af_enum, cNeuron, Layer } from "./NN_classes.ts";
55
import {
66
hiddenLayersCount_store,
77
hiddenLayersNeuronCount_store,
88
selActivaFn_store,
99
randomisedVals_store,
10+
hidOutLayers_store,
11+
currentNeuron_store,
1012
} from "../store.ts";
11-
import { setPreference } from "../../lib/db/localStorage.ts";
13+
import {
14+
deleteEverything,
15+
setPreference,
16+
} from "../../lib/db/localStorage.ts";
1217
import { onMount } from "svelte";
1318
1419
let loading = $state(true);
@@ -44,12 +49,29 @@
4449
activationFns.find((fn) => fn.name == $selActivaFn_store)?.theme || "",
4550
);
4651
});
52+
53+
function resetAllParams() {
54+
deleteEverything();
55+
$hiddenLayersNeuronCount_store = [1];
56+
$hiddenLayersCount_store = 1;
57+
$selActivaFn_store = af_enum.relu;
58+
$randomisedVals_store = false;
59+
$hidOutLayers_store.map((layer) => {
60+
layer.neurons.map((neuron) => {
61+
neuron.bias = 0;
62+
neuron.weights.map((weight) => {
63+
weight = 0;
64+
});
65+
});
66+
});
67+
$currentNeuron_store = new cNeuron(0, 0);
68+
}
4769
</script>
4870

4971
<div
50-
class="mx-auto w-max rounded-btn grid sm:grid-cols-3 grid-cols-2 sm:gap-12 gap-5 mb-4 *:flex *:flex-col *:justify-between *:h-full *:gap-2"
72+
class="mx-auto w-max rounded-btn grid sm:grid-cols-4 grid-cols-2 sm:gap-12 gap-5 gap-x-12 mb-4 *:flex *:flex-col *:justify-between *:h-full *:gap-2"
5173
>
52-
<div class="">
74+
<div class="items-end">
5375
<p class="text-gray-400 text-sm">Hidden layers</p>
5476
<div class="relative1 max-w-xs text-gray-300">
5577
<div
@@ -141,12 +163,18 @@
141163
</ul>
142164
</div>
143165
</div>
144-
<div class=" ">
166+
<div class="sm:items-center items-end">
145167
<p class="text-gray-400 text-sm">Randomised?</p>
146168
<input
147169
type="checkbox"
148170
class="toggle toggle-lg w-16 h-8"
149171
bind:checked={$randomisedVals_store}
150172
/>
151173
</div>
174+
<div>
175+
<p class="text-gray-400 text-sm">Reset All Params</p>
176+
<button aria-label="Reset" class="btn" onclick={resetAllParams}>
177+
<div class="i-tabler:reload size-7"></div>
178+
</button>
179+
</div>
152180
</div>

0 commit comments

Comments
 (0)