Commit cac3d7b1 authored by Petr Kubeš's avatar Petr Kubeš

polishing

parent f7fd6cd7
[Dolphin]
Timestamp=2018,7,22,18,0,30
Timestamp=2018,7,24,23,29,56
Version=4
[Settings]
HiddenFilesShown=true
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -13,7 +13,6 @@
<script src="./dist/main.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async></script>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-3364556172084454",
......@@ -122,9 +121,10 @@
<div class="row mb-3">
<div class="col-md-auto">
<input type="checkbox">
<label>Repeat</label>
<button type="button" class="btn btn-primary mr-2" onclick="train(true)">Train</button>
<label style="margin: 8px">
<input type="checkbox" style="margin-right: 4px" id="train-repeat-chckbx">Repeat
</label>
<button type="button" id="train-btn" class="btn btn-primary mr-2" onclick="train(true)">Train</button>
<button type="button" class="btn btn-secondary" onclick="train(false)">Step</button>
<button type="button" class="btn btn-danger" onclick="reset()">Reset</button>
</div>
......@@ -148,7 +148,7 @@
<p>
Let's say that the value of connection is the connection's weight (how wide it is) times the first connected neuron. To calculate
the value of some neuron you add the values of all incoming connections and apply the
<a href="https://www.desmos.com/calculator/dw9fmqwlmn">sigmoid</a> function the that sum. Other activation functions are possible, but I have not implemented them yet.
<a target="_blank" href="https://www.desmos.com/calculator/dw9fmqwlmn">sigmoid</a> function the that sum. Other activation functions are possible, but I have not implemented them yet.
</p>
<h5>Back propagation</h5>
<p>
......@@ -159,20 +159,30 @@
the cost. In equation: \(w_{new} = w_{old} - rate \times \frac{\partial C}{\partial w_{old}}\). How to compute the
derivative is a little bit harder, but all you need to know is the
<i>chain rule</i>. I highly recommend
<a href="https://www.youtube.com/watch?v=aircAruvnKk">3blue1brown's series</a> and
<a href="https://web.archive.org/web/20150317210621/https://www4.rgu.ac.uk/files/chapter3%20-%20bp.pdf">this paper</a> for better understanding.
<a target="_blank" href="https://www.youtube.com/watch?v=aircAruvnKk">3blue1brown's series</a> and
<a target="_blank" href="https://web.archive.org/web/20150317210621/https://www4.rgu.ac.uk/files/chapter3%20-%20bp.pdf">this paper</a> for better understanding.
</p>
<h5>Inpiration</h5>
<p>
I got inspired by the
<a href="https://playground.tensorflow.org">https://playground.tensorflow.org</a> and
<a href="https://cs.stanford.edu/people/karpathy/convnetjs/">https://cs.stanford.edu/people/karpathy/convnetjs/</a>, but I wanted something simpler and build it myself from the
<a target="_blank" href="https://playground.tensorflow.org">https://playground.tensorflow.org</a> and
<a target="_blank" href="https://cs.stanford.edu/people/karpathy/convnetjs/">https://cs.stanford.edu/people/karpathy/convnetjs/</a>, but I wanted something simpler and build it myself from the
ground up.
</p>
<footer class="futter m-5" style="text-align: center;">
Created by
<a href="mailto:petrkubes1997@gmail.com?Subject=Nerual%20network%20-%20suggestion/hate/or%20just%20saying%20hi" target="_top">Petr Kubeš</a>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" style="font-size: 0.8em">
If you like this, I would highly appreciate a small donation to help me with development of more features and more neural
network types in the future.
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHbwYJKoZIhvcNAQcEoIIHYDCCB1wCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBpgHwAKMnpAkmTpiIHdB/UD+Exp2Ck4Z0fWdAbkOgNeMEOLUyElmJHsW/EqtHJUrnUF8R8KmRA/P4F7L8KVEYCSAjHhzgjBmFoO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gdGXQlQ78pRtFzmnmQzYIejxJoE=-----END PKCS7-----
">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/cs_CZ/i/scr/pixel.gif" width="1" height="1">
</form>
<br> Created by
<a target="_blank" href="mailto:petrkubes1997@gmail.com?Subject=Nerual%20network%20-%20suggestion/hate/or%20just%20saying%20hi"
target="_top">Petr Kubeš</a>
</footer>
</div>
......
......@@ -20,4 +20,8 @@ input[type=range][orient=vertical]
writing-mode: bt-lr; /* IE */
-webkit-appearance: slider-vertical; /* WebKit */
width: 8px;
}
.checkbox {
margin-right: 15px;
}
\ No newline at end of file
......@@ -126,8 +126,8 @@ export class Visualizer {
Math.log(weight) :
Math.log(-weight);
this.ctx.strokeStyle = (weight > 0) ?
`rgba(205, 83, 52, 1)` :
`rgba(61, 232, 255, 1)`;
`rgba(61, 232, 255, 1)` :
`rgba(205, 83, 52, 1)`;
this.ctx.moveTo(inputNeuron.x, inputNeuron.y);
this.ctx.lineTo(outputNeuron.x, outputNeuron.y);
this.ctx.closePath();
......
......@@ -45,10 +45,22 @@ import { Neuron } from './neuralNetwork/Neuron';
neuralCore.setRegularizationRate(Number.parseFloat(regRateInput.value));
if (trainRepeat.checked && interval == null) {
trainBtn.innerText = "Stop"
interval = setInterval(() => { runTrainLoop(iters) }, 100);
} else if (interval != null) {
clearInterval(interval);
interval = null;
trainBtn.innerText = "Start"
} else {
runTrainLoop(iters);
}
}
const runTrainLoop = (iters: number) => {
for (let i = 0; i < iters; i++) {
neuralCore.train();
}
updateUI();
}
......@@ -59,7 +71,7 @@ import { Neuron } from './neuralNetwork/Neuron';
dataArr.forEach((sample) => {
neuralCore.addTrainingSet(sample[0], sample[1]);
});
neuralCore.reset();
updateUI();
} catch (err) {
alert(err);
......@@ -83,10 +95,12 @@ window.onload = () => {
let neuralCore: NeuralCore;
let visualizer: Visualizer;
let input: number[];
let interval = null;
let inputSize = 2;
let hiddenSizes = [3];
let outputSize = 1;
let layerControls: HTMLElement;
let inputControls: HTMLElement;
let canvas: HTMLCanvasElement;
......@@ -98,6 +112,8 @@ let rateInput: HTMLInputElement;
let itersInput: HTMLInputElement;
let regTypeInput: HTMLInputElement;
let regRateInput: HTMLInputElement;
let trainRepeat: HTMLInputElement;
let trainBtn: HTMLInputElement;
let trainingSetLabelsOutput: HTMLElement;
let trainingSetDataOutput: HTMLElement;
......@@ -116,6 +132,8 @@ const main = () => {
trainingSetDataOutput = document.getElementById('training-set-data-output') as HTMLInputElement;
trainingSetLabelsOutput = document.getElementById('training-set-neurons-output') as HTMLInputElement;
trainingSetInput = document.getElementById('training-set-input') as HTMLInputElement;
trainRepeat = document.getElementById('train-repeat-chckbx') as HTMLInputElement;
trainBtn = document.getElementById('train-btn') as HTMLInputElement;
visualizer = new Visualizer(canvas);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment