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
#extension GL_EXT_draw_buffers : require | |
precision highp float; | |
precision highp int; | |
precision highp sampler2D; | |
const float LOOP_MAX = 100.0; | |
#define EPSILON 0.0000001; | |
uniform highp vec3 uOutputDim; | |
uniform highp vec2 uTexSize; |
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
//existing neural net | |
class NeuralNetwork { | |
runInput(input) { | |
this.outputs[0] = input; // set output state of input layer | |
let output = null; | |
for (let layer = 1; layer <= this.outputLayer; layer++) { | |
for (let node = 0; node < this.sizes[layer]; node++) { | |
let weights = this.weights[layer][node]; |
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
gl.activeTexture(gl[outputTextureName]); | |
gl.bindTexture(gl.TEXTURE_2D, outputTexture); | |
if (this.subKernelOutputTextures !== null) { | |
for (let i = 0; i < this.subKernelOutputTextures.length; i++) { | |
const subKernelOutputTextureName = this.subKernelOutputTextureNames[i]; | |
const outputTextureName = `TEXTURE${ paramNames.length + i + 1 }`; | |
const subKernelOutputTexture = this.subKernelOutputTextures[i]; | |
gl.activeTexture(gl[outputTextureName]); | |
gl.bindTexture(gl.TEXTURE_2D, subKernelOutputTexture); | |
} |
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
import GPU from 'gpu'; | |
import brain from './src'; | |
function relu(value) { | |
return Math.max(0, value); | |
} | |
function reluBackpropagate(weight, delta) { | |
return weight[this.thread.y][this.thread.x] > 0 ? delta[this.thread.y][this.thread.x] : 0; | |
} |
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
/// | |
/// gpu.js | |
/// http://gpu.rocks/ | |
/// | |
/// GPU Accelerated JavaScript | |
/// | |
/// @version 0.0.0 | |
/// @date Tue Feb 28 2017 11:41:57 GMT+0800 (SGT) | |
/// | |
/// @license MIT |
This file has been truncated, but you can view the full file.
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
function anonymous(convolutionFilters,convolutionInputs,convolutionOutputs,convolutionBiases | |
/**/) { | |
var convolutionWeight; | |
var convolutionFilterWeights; | |
convolutionFilterWeights = convolutionFilters[0]; | |
convolutionInputDeltas[-84] = 0; | |
convolutionInputDeltas[-83] = 0; | |
convolutionInputDeltas[-82] = 0; | |
convolutionInputDeltas[-81] = 0; | |
convolutionInputDeltas[-80] = 0; |
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
it('can predict a phrase when given the first letter', () => { | |
const phrase = 'bob'; | |
const vocab = new Vocab(['b', 'o']); | |
const net = new GRU({ | |
inputSize: 3, | |
inputRange: vocab.characters.length, | |
outputSize: 3 | |
}); | |
for (var i = 0; i < 100; i++) { | |
//train |
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
//I put this in | |
describe('printable characters', () => { | |
it('poc', () => { | |
const vocab = Vocab.allPrintable(); | |
var net = new GRU({ | |
inputSize: 100, | |
inputRange: vocab.characters.length, | |
outputSize: 100 | |
}); |
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
function anonymous(input | |
/**/) { | |
var model = {"type":"LSTM","options":{"inputSize":6,"inputRange":15,"hiddenSizes":[20,20],"outputSize":15,"learningRate":0.01,"decayRate":0.999,"smoothEps":1e-8,"regc":0.000001,"clipval":5,"json":null},"input":{"rows":16,"columns":6,"weights":{"0":0.2750181314653913,"1":-0.5240159623884509,"2":-0.408752201001415,"3":-0.448984608652921,"4":-0.9331697140323069,"5":-0.7128413103096853,"6":0.35645014914363216,"7":0.7092642368068771,"8":-0.40205570626482884,"9":0.18009240823681072,"10":0.3864554416636306,"11":0.6294286754915727,"12":-0.49146111951010446,"13":-0.5134531804578492,"14":0.08656950701151409,"15":0.10822482362090162,"16":0.8152555658106171,"17":0.014161649394307032,"18":0.5886991063098534,"19":-0.03284264424828155,"20":-0.33622210044702217,"21":0.11700147917839701,"22":0.2512207366661221,"23":1.357894991603078,"24":0.5572135751870317,"25":0.33195733965195273,"26":-0.21192128398950427,"27":-0.028280711815505764,"28":0.2782813838154882,"29":0.9870090189467543,"30":0 |
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
function anonymous(input | |
/**/) { | |
var model = {"type":"RNN","options":{"inputSize":3,"inputRange":2,"hiddenSizes":[3],"outputSize":2,"learningRate":0.01,"decayRate":0.999,"smoothEps":1e-8,"regc":0.000001,"clipval":5,"json":null},"input":{"rows":3,"columns":3,"weights":{"0":0.14504642918678196,"1":0.28865358965723514,"2":-0.3079530522503993,"3":-0.13441059098438157,"4":-0.3943911782285204,"5":0.22545938148786127,"6":-0.19453870088510053,"7":-0.3184347404294077,"8":0.3309666089021073}},"hiddenLayers":[{"weight":{"rows":3,"columns":3,"weights":{"0":0.16208498769941176,"1":0.043981900440411704,"2":0.06736829422601728,"3":0.11339363189835776,"4":-0.028364202776012152,"5":-0.038854912606870705,"6":-0.2981753114004179,"7":0.40875294934195483,"8":0.23295964074505185}},"transition":{"rows":3,"columns":3,"weights":{"0":0.01913355746381583,"1":-0.06787170641122188,"2":0.014116139090044852,"3":0.035298424320335434,"4":0.04757889342466173,"5":0.025314592304064076,"6":0.019473188112568866,"7":0.0009661367633043027,"8":-0 |