Skip to content

Instantly share code, notes, and snippets.

View robertleeplummerjr's full-sized avatar

Robert Plummer robertleeplummerjr

View GitHub Profile
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
filters x=0,y=0,z=0 inputs
width=6,height=6,depth=2 width=4,height=4,depth=2
[*][ ][ ][ ][ ][ ] * _ [*][ ][*][ ] *
[ ][ ][ ][ ][ ][ ] _ [ ][ ][ ][ ] _
[ ][ ][ ][ ][ ][ ] * _ [*][ ][*][ ] *
[ ][ ][ ][ ][ ][ ] _ [ ][ ][ ][ ] _
[ ][ ][ ][ ][ ][ ] * _ * _ * _ *
[ ][ ][ ][ ][ ][ ]
[ ][ ][ ][ ]
[ ][ ][ ][ ]
@robertleeplummerjr
robertleeplummerjr / fake-free-restaurants.json
Created September 2, 2018 17:51
Contrived data for a machine learning course on brain.js
{
"Vegetable Bar and Gril": ["Monday"],
"Southern North America Grill": ["Sunday"],
"Behind The House Burgers": ["Tuesday"],
"Robert Evans": ["Tuesdays"],
"Brewwwi": ["Monday"],
"Currows": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
"Seeby & Buckets": ["Thursday"],
"Captain E’s": ["Thursday"],
"The Delusion Last Railway Car": ["Thursday"],
const convnet = require('./build/convnet');
const v = new convnet.Vol(2,2,1);
v.set(0, 0, 0, 1);
v.set(0, 1, 0, 2);
v.set(1, 0, 0, 3);
v.set(1, 1, 0, 4);
// const output = convnet.FullyConnLayer.prototype.forward.call({
class StaticBridge {
public static build<T>(Type: T, c: Api): any {
return Object.getOwnPropertyNames(Type)
.filter((prop) => typeof Type[prop] === "function")
.reduce((methods, method) => ({
// tslint:disable-next-line:no-any
...methods as any,
[method]: async (v: any): Promise<any> => {
return Type[method](v, c);
},
@robertleeplummerjr
robertleeplummerjr / feed-forward.js
Last active December 7, 2017 14:53
a brain.js feed-forward layer
import {
add,
multiply,
random,
sigmoid
} from './';
export default function feedForward(settings, input) {
const { width, height } = settings;
const weights = random({ width, height });
@robertleeplummerjr
robertleeplummerjr / dch.ts
Created October 28, 2017 22:13
Dynamic Class Hierarchy in Typescript
class Item {
public static async get<Options extends { id: string }>(o: Options, api: Api): Promise<Item> {
return new Promise<Item>((accept, reject) => {
console.log(api);
accept(new Item());
});
}
public static async search<Options extends { query: string }>(o: Options, api: Api): Promise<Item[]> {
return new Promise<Item[]>((accept, reject) => {
//This will come in handy
import { AxiosStatic } from "axios";
import { Container } from "inversify";
import Request from "../request";
class AxiosCoreMock implements AxiosCore {}
const container = new Container();
container.bind(Request).toSelf();
container.bind<AxiosCore>("axios").toConstantValue(new AxiosCoreMock());
function round(a) {
return Math.floor(a + 0.5);
};
function vectorDotProduct(V1x, V1y, V1z, V2x, V2y, V2z) {
return (V1x * V2x) + (V1y * V2y) + (V1z * V2z);
};
function unitVectorX(Vx, Vy, Vz) {
var magnitude = Math.sqrt((Vx * Vx) + (Vy * Vy) + (Vz * Vz));
const outputTextureName = `TEXTURE${ paramNames.length + i + 1 }`;
const subKernelOutputTexture = this.subKernelOutputTextures[i];
gl.activeTexture(gl[outputTextureName]);
gl.bindTexture(gl.TEXTURE_2D, subKernelOutputTexture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
if (this.floatOutput) {
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.FLOAT, null);