<commit_before><script src="https://cdnjs.cloudflare.com/ajax/libs/synaptic/1.1.4/synaptic.js"></script>


<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>


<script>

var input = new synaptic.Layer(2); // Two inputs
var output = new synaptic.Layer(3); // Three outputs



var trainingData = [
    {input: [1, 0], output: [1, 0, 0]}, // Clap -> Sit
    {input: [0, 1], output: [0, 1, 0]}, // Whistle -> Run
    {input: [1, 1], output: [0, 0, 1]}, // Clap+Whistle -> Jump
];



var learningRate = 0.4;
 
function train() {
    for(var i = 0; i < trainingData.length; i++) {
        input.activate(trainingData[i]["input"]);
        output.activate();
        output.propagate(learningRate, trainingData[i]["output"]);
    }
}

function retrain() {
    for(var i = 0; i < 1000; i++) {
        trainingData = _.shuffle(trainingData);
        train();
    }
}
 
retrain(); // Start the training

input.activate([1,0]); // Whistle
var result = output.activate();


console.log("Sit Neuron: " + result[0] * 100 + "%");
console.log("Run Neuron: " + result[1] * 100 + "%");
console.log("Jump Neuron: " + result[2] * 100 + "%");

document.getElementBuid().innerHTML = 'Run Neuron: ' + result[1] * 100 + '%'
</script>






Open the console using ctrl-shift-i<br>


<div "">...</div>
<commit_msg>Update whistle-clap01.html<commit_after><script src="https://cdnjs.cloudflare.com/ajax/libs/synaptic/1.1.4/synaptic.js"></script>


<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>


<script>

var input = new synaptic.Layer(2); // Two inputs
var output = new synaptic.Layer(3); // Three outputs



var trainingData = [
    {input: [1, 0], output: [1, 0, 0]}, // Clap -> Sit
    {input: [0, 1], output: [0, 1, 0]}, // Whistle -> Run
    {input: [1, 1], output: [0, 0, 1]}, // Clap+Whistle -> Jump
];



var learningRate = 0.4;
 
function train() {
    for(var i = 0; i < trainingData.length; i++) {
        input.activate(trainingData[i]["input"]);
        output.activate();
        output.propagate(learningRate, trainingData[i]["output"]);
    }
}

function retrain() {
    for(var i = 0; i < 1000; i++) {
        trainingData = _.shuffle(trainingData);
        train();
    }
}
 
retrain(); // Start the training

input.activate([1,0]); // Whistle
var result = output.activate();


console.log("Sit Neuron: " + result[0] * 100 + "%");
console.log("Run Neuron: " + result[1] * 100 + "%");
console.log("Jump Neuron: " + result[2] * 100 + "%");

document.getElementBuid().innerHTML = 'Run Neuron: ' + result[1] * 100 + '%'
</script>






Open the console using ctrl-shift-i<br>

<input type=button value=run onclick="{
                                      
alert('Run Neuron: ' + result[1] * 100 + '%')
                                      }">
<div "">...</div>

{'fraction_non_alphanumeric': 0.2047569803516029, 'fraction_numerical': 0.035849706997587036, 'mean_word_length': 2.932249322493225, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 28, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '983726', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1004, 'n_words': 223}