Skip to content

Instantly share code, notes, and snippets.

@robertleeplummerjr
Last active October 6, 2018 02:39
Show Gist options
  • Select an option

  • Save robertleeplummerjr/7680d0a3582418066015885f531823cb to your computer and use it in GitHub Desktop.

Select an option

Save robertleeplummerjr/7680d0a3582418066015885f531823cb to your computer and use it in GitHub Desktop.
export function compareFilters(filterDeltas, inputs, deltas) {
const startingInputY = this.thread.y - this.constants.paddingY
const startingInputX = this.thread.x - this.constants.paddingX
let deltaSlideY = 0
let sum = filterDeltas[this.thread.z][this.thread.y][this.thread.x]
for (let y = 0; y < this.constants.slideHeight; y++) {
deltaSlideY++
let deltaSlideX = 0
const inputY = startingInputY + (y * this.constants.strideY)
if (inputY < 0 || inputY >= this.constants.inputHeight) continue
for (let x = 0; x < this.constants.slideWidth; x++) {
deltaSlideX++
const inputX = startingInputX + (x * this.constants.strideX)
if (inputX < 0 || inputX >= this.constants.inputWidth) continue
const input = inputs[this.thread.z][inputY][inputX]
const deltaY = deltaSlideY - 1;
const deltaX = deltaSlideX - 1;
sum += input * deltas[this.constants.deltaZ][deltaY][deltaX]
}
}
return sum
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment