/*
/*
* Copyright 2021 Markus Heimerl, OTH Regensburg
* Licensed under CC BY-NC 4.0
*
* ANY USE OF THIS SOFTWARE MUST COMPLY WITH THE
* CREATIVE COMMONS ATTRIBUTION-NONCOMMERCIAL 4.0 INTERNATIONAL LICENSE
* AGREEMENTS
*/
var malloc = Module.cwrap('malloc', 'number', ['number']);
var predict = Module.cwrap('predict', 'number', ['string', 'number']);
var getImages = Module.cwrap('getImages', 'number', ['string', 'number']);
var evaluateNetwork = Module.cwrap('evaluateNetwork', 'number', ['string', 'number']);
var printImage = Module.cwrap('printImage', 'number', ['number']);
var getAllNeuronsAndWeights = Module.cwrap('getAllNeuronsAndWeights', 'number', ['string']);
var printSingleNeuron = Module.cwrap('printSingleNeuron', 'number', ['number']);
var getWeightValueAsString = Module.cwrap('getWeightValueAsString', 'string', ['number', 'number']);
var getBiasValueAsString = Module.cwrap('getBiasValueAsString', 'string', ['number']);
var getNeuronValueAsString = Module.cwrap('getNeuronValueAsString', 'string', ['number']);
var predictHardcoded = Module.cwrap('predictHardcoded', 'number', ['number', 'number']);
var stepFeedNetwork = Module.cwrap('stepFeedNetwork', 'number', ['number', 'number', 'number']);
var stepFeedForward = Module.cwrap('stepFeedForward', 'number', ['number', 'number', 'number', 'number']);
var fastForwardFeedForwardOfThisLayer = Module.cwrap('fastForwardFeedForwardOfThisLayer', 'number', ['number', 'number', 'number', 'number']);
var stepApplySigmoid = Module.cwrap('stepApplySigmoid', 'number', ['number', 'number']);
var canvas = $("#multilayerperceptroncanvas")[0];
var ctx = canvas.getContext("2d");
var neuronsobject = {};
var globalinputdatapointer = -1;
var infoimage = -1;
var ffphasestring = "None";
var running = false;
function readIntFromHeap(u8addr){
var addr = 0;
addr = addr | HEAPU8[u8addr+3];
addr = addr << 8;
addr = addr | HEAPU8[u8addr+2];
addr = addr << 8;
addr = addr | HEAPU8[u8addr+1];
addr = addr << 8;
addr = addr | HEAPU8[u8addr+0];
return addr;
}
function printNeuron(arr, neuronindex){
printSingleNeuron(readIntFromHeap(arr+4*neuronindex));
}
function getWeight(arr, neuronindex, weightindex, biasandweightsvaluebuffer){
return getWeightValueAsString(readIntFromHeap(arr+4*neuronindex), weightindex, biasandweightsvaluebuffer);
}
function getNeuron(arr, neuronindex, biasandweightsvaluebuffer){
return getNeuronValueAsString(readIntFromHeap(arr+4*neuronindex), biasandweightsvaluebuffer);
}
function getBias(arr, neuronindex, biasandweightsvaluebuffer){
return getBiasValueAsString(readIntFromHeap(arr+4*neuronindex), biasandweightsvaluebuffer);
}
function resizeTo(canvas, xscale, yscale, x_min, y_min){
var context = canvas.getContext("2d");
var imageData = context.getImageData(0, 0, canvas.width, canvas.height);
var newCanvas = $("