This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
target_branch="gh-pages" | |
working_tree="/home/meherranjan/aerosailor.com" | |
while read oldrev newrev refname | |
do | |
branch=$(git rev-parse --symbolic --abbrev-ref $refname) | |
if [ -n "$branch" ] && [ "$target_branch" == "$branch" ]; then | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sortedList = [1,2,3,4,5,6,9,11,12,13,14,15,16,17,18,19,20] | |
const binarySearch = (list, item) => { | |
let low = 0 | |
let high = list.length - 1 | |
let guess = null | |
while(low <= high) { | |
let mid = Math.floor((high + low)/2) | |
guess = list[mid] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sortedList = [11, 24, 33, 64, 95, 106, 217, 228, 299, 310] | |
const getMid = (low, high) => { | |
return Math.floor((high + low) / 2) | |
} | |
const recursiveBS = (list, item, low, high) => { | |
(!low && !high ) && (low = 0, high = list.length - 1) | |
let found = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const trainingData = [ | |
[4, 8, 0], | |
[4, 2, 0], | |
[5, 7, 0], | |
[7, 4, 0], | |
[9, 9, 1], | |
[7, 10, 1], | |
[10, 12, 1], | |
[3, 12, 1] | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getRandomWeights = () => Array.from({ length: 2 }, () => Math.random() * 0.5 - 0.2) | |
const getRandomBias = () => Math.random() * 0.5 - 0.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getInput = (data, index) => data[index]; | |
const getTarget = input => [...input].pop(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getWeightedInputSum = (input, weight, bias) => weight[0] * input[0] + weight[1] * input[1] + bias; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sigmoid = sum => 1 / (1 + Math.exp(-sum)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const trainModel = data => { | |
let weights = getRandomWeights(); | |
let bias = getRandomBias(); | |
for (let i = 0; i < 50000; i++) { | |
const randomIndex = getRandomIndex(data.length); | |
const input = getInput(data, randomIndex); | |
const target = getTarget(input); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (let i = 0; i < 50000; i++) { | |
... | |
... | |
const weightedSum = getWeightedInputSum(weights, input, bias); | |
const weightedSumWRTweight0 = input[0]; | |
const weightedSumWRTweight1 = input[1]; | |
const weightedSumWRTbias = 1; | |
const prediction = compose( | |
sigmoid, |
OlderNewer