MCPcopy
hub / github.com/BrainJS/brain.js / buildGetChanges

Method buildGetChanges

src/neural-network-gpu.js:196–236  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

194 }
195
196 buildGetChanges() {
197 for (let layer = 1; layer <= this.outputLayer; layer++) {
198 this.changesPropagate[layer] = this.gpu.createKernelMap({
199 weights: GPU.alias('addWeights', addWeights),
200 changes: GPU.alias('calcChanges', calcChanges)
201 },
202 function(previousOutputs, deltas, weights, changes) {
203 let change = calcChanges(
204 changes,
205 deltas,
206 previousOutputs);
207
208 return addWeights(change, weights);
209 }, {
210 output: [this.sizes[layer - 1], this.sizes[layer]],
211 outputToTexture: true,
212 hardcodeConstants: true,
213 constants:{
214 size: this.outputs[layer - 1].length,
215 learningRate: this.trainOpts.learningRate,
216 momentum: this.trainOpts.momentum
217 }
218 });
219
220 this.copyChanges[layer] = this.gpu.createKernel(function(value) {
221 return value[this.thread.y][this.thread.x];
222 }, {
223 output: this.changesPropagate[layer].output,
224 outputToTexture: true,
225 hardCodeConstants: true
226 });
227
228 this.copyWeights[layer] = this.gpu.createKernel(function(value) {
229 return value[this.thread.y][this.thread.x];
230 }, {
231 output: this.changesPropagate[layer].output,
232 outputToTexture: true,
233 hardCodeConstants: true
234 });
235 }
236 }
237
238 getChanges() {
239 for (let layer = 1; layer <= this.outputLayer; layer++) {

Callers 3

_initializeMethod · 0.95
browser.min.jsFile · 0.80
browser.jsFile · 0.80

Calls 2

calcChangesFunction · 0.70
addWeightsFunction · 0.70

Tested by

no test coverage detected