How to use f2 method in Airtest

Best Python code snippet using Airtest

main.js

Source:main.js Github

copy

Full Screen

1/*2​x=r sin(φ)cos(θ)3​y=r sin(φ)sin(θ)4​z=r cos(φ)5*/6/* DATA SAMPLE TEMPLATE7{8 Thermo1 Object Temp,9 Thermo2 Object Temp,10 Thermo3 Object Temp,11 Thermo4 Object Temp,12 Distance,13 Pitch,14 Roll,15 Acc X,16 Acc Y,17 Acc Z,18 Thermo Ave. Device Temp,19 Time Stamp,20 Hand,21 Target,22 on/off Target Observed23}*/24var preProcess = 2; //THERMOPILE PREPROCESSING NORMALIZATION METHOD SELECTION25//sensor data object26var state = {};27 // Web Bluetooth connection -->28$( document ).ready(function() {29 button = document.getElementById("connect");30 message = document.getElementById("message");31});32//connection flag33var bluetoothDataFlag = false;34if ( 'bluetooth' in navigator === false ) {35 button.style.display = 'none';36 message.innerHTML = 'This browser doesn\'t support the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Bluetooth_API" target="_blank">Web Bluetooth API</a> :(';37}38const services = {39 controlService: {40 name: 'control service',41 uuid: '0000a000-0000-1000-8000-00805f9b34fb'42 }43}44const characteristics = {45 commandReadCharacteristic: {46 name: 'command read characteristic',47 uuid: '0000a001-0000-1000-8000-00805f9b34fb'48 },49 commandWriteCharacteristic: {50 name: 'command write characteristic',51 uuid: '0000a002-0000-1000-8000-00805f9b34fb'52 },53 deviceDataCharacteristic: {54 name: 'imu data characteristic',55 uuid: '0000a003-0000-1000-8000-00805f9b34fb'56 }57}58var _this;59var state = {};60var previousPose;61var sendCommandFlag = false; //global to keep track of when command is sent back to device62//let commandValue = new Uint8Array([0x01,0x03,0x02,0x03,0x01]); //command to send back to device63let commandValue = new Uint8Array([0x99]); //command to send back to device64class ControllerWebBluetooth {65 constructor(name) {66 _this = this;67 this.name = name;68 this.services = services;69 this.characteristics = characteristics;70 this.standardServer;71 }72 connect() {73 return navigator.bluetooth.requestDevice({74 filters: [{75 name: this.name76 },77 {78 services: [services.controlService.uuid]79 }80 ]81 })82 .then(device => {83 console.log('Device discovered', device.name);84 return device.gatt.connect();85 })86 .then(server => {87 console.log('server device: ' + Object.keys(server.device));88 this.getServices([services.controlService, ], [characteristics.commandReadCharacteristic, characteristics.commandWriteCharacteristic, characteristics.deviceDataCharacteristic], server);89 })90 .catch(error => {91 console.log('error', error)92 })93 }94 getServices(requestedServices, requestedCharacteristics, server) {95 this.standardServer = server;96 requestedServices.filter((service) => {97 if (service.uuid == services.controlService.uuid) {98 _this.getControlService(requestedServices, requestedCharacteristics, this.standardServer);99 }100 })101 }102 getControlService(requestedServices, requestedCharacteristics, server) {103 let controlService = requestedServices.filter((service) => {104 return service.uuid == services.controlService.uuid105 });106 let commandReadChar = requestedCharacteristics.filter((char) => {107 return char.uuid == characteristics.commandReadCharacteristic.uuid108 });109 let commandWriteChar = requestedCharacteristics.filter((char) => {110 return char.uuid == characteristics.commandWriteCharacteristic.uuid111 });112 // Before having access to IMU, EMG and Pose data, we need to indicate to the Myo that we want to receive this data.113 return server.getPrimaryService(controlService[0].uuid)114 .then(service => {115 console.log('getting service: ', controlService[0].name);116 return service.getCharacteristic(commandWriteChar[0].uuid);117 })118 .then(characteristic => {119 console.log('getting characteristic: ', commandWriteChar[0].name);120 // return new Buffer([0x01,3,emg_mode,imu_mode,classifier_mode]);121 // The values passed in the buffer indicate that we want to receive all data without restriction;122 // let commandValue = new Uint8Array([0x01,0x03,0x02,0x03,0x01]);123 //this could be config info to be sent to the wearable device124 let commandValue = new Uint8Array([0x99]);125 // characteristic.writeValue(commandValue); //disable initial write to device126 })127 .then(_ => {128 let deviceDataChar = requestedCharacteristics.filter((char) => {129 return char.uuid == characteristics.deviceDataCharacteristic.uuid130 });131 console.log('getting service: ', controlService[0].name);132 _this.getdeviceData(controlService[0], deviceDataChar[0], server);133 })134 .catch(error => {135 console.log('error: ', error);136 })137 }138 sendControlService(requestedServices, requestedCharacteristics, server) {139 let controlService = requestedServices.filter((service) => {140 return service.uuid == services.controlService.uuid141 });142 let commandReadChar = requestedCharacteristics.filter((char) => {143 return char.uuid == characteristics.commandReadCharacteristic.uuid144 });145 let commandWriteChar = requestedCharacteristics.filter((char) => {146 return char.uuid == characteristics.commandWriteCharacteristic.uuid147 });148 // Before having access to sensor, we need to indicate to the Tingle that we want to receive this data.149 return server.getPrimaryService(controlService[0].uuid)150 .then(service => {151 console.log('getting service: ', controlService[0].name);152 return service.getCharacteristic(commandWriteChar[0].uuid);153 })154 .then(characteristic => {155 console.log('getting write command to device characteristic: ', commandWriteChar[0].name);156 // return new Buffer([0x01,3,emg_mode,imu_mode,classifier_mode]);157 // The values passed in the buffer indicate that we want to receive all data without restriction;158 let commandValue = new Uint8Array([0x99]);159 getConfig();160 commandValue[0] = targetCommand;161 console.log("CONFIG target:" + activeTarget + " command:" + commandValue[0]);162 characteristic.writeValue(commandValue);163 })164 .then(_ => {165 // let deviceDataChar = requestedCharacteristics.filter((char) => {return char.uuid == characteristics.deviceDataCharacteristic.uuid});166 console.log("COMMAND SENT TO DEVICE");167 sendCommandFlag = false;168 // console.log('getting service: ', controlService[0].name);169 // _this.getdeviceData(controlService[0], deviceDataChar[0], server);170 })171 .catch(error => {172 sendCommandFlag = false;173 console.log("COMMAND SEND ERROR");174 console.log('error: ', error);175 })176 }177 handleDeviceDataChanged(event) {178 //byteLength of deviceData DataView object is 20.179 // deviceData return {{orientation: {w: *, x: *, y: *, z: *}, accelerometer: Array, gyroscope: Array}}180 let deviceData = event.target.value;181 let accelerometerRoll = ( (event.target.value.getUint8(0) / 255) * 360 );182 let accelerometerPitch = ( (event.target.value.getUint8(1) / 255) * 360 );183 let proximity = (event.target.value.getUint8(2) );184 let objectTemp1 = (event.target.value.getUint8(3) / 8) + 70;185 let objectTemp2 = (event.target.value.getUint8(4) / 8) + 70;186 let objectTemp3 = (event.target.value.getUint8(5) / 8) + 70;187 let objectTemp4 = (event.target.value.getUint8(6) / 8) + 70;188 let ambientAverage = (event.target.value.getUint8(7) / 8) + 70;189 let batteryVoltage = (event.target.value.getUint8(8) );190 let deviceCommand = (event.target.value.getUint8(9) );191 let accelerometerX = (event.target.value.getUint8(10) / 100) - 1;192 let accelerometerY = (event.target.value.getUint8(11) / 100) - 1;193 let accelerometerZ = (event.target.value.getUint8(12) / 100) - 1;194 let objectTemp1norm = (event.target.value.getUint8(13) / 255 );195 let objectTemp2norm = (event.target.value.getUint8(14) / 255 );196 let objectTemp3norm = (event.target.value.getUint8(15) / 255 );197 let objectTemp4norm = (event.target.value.getUint8(16) / 255 );198 let deviceNN5 = (event.target.value.getUint8(17) / 255 );199 let deviceNN7 = (event.target.value.getUint8(18) / 255 );200 console.log(accelerometerRoll + " " + accelerometerPitch + " " + proximity + " " + objectTemp1 + " " + objectTemp2 + " " + objectTemp3 + " " + objectTemp4 + " " + objectTemp1norm + " " + objectTemp2norm + " " + objectTemp3norm + " " + objectTemp4norm + " " + ambientAverage + " " + batteryVoltage);201 console.log("DEVICE NN5: " + deviceNN5 + " DEVICE NN7: " + deviceNN7);202 var data = {203 accelerometer: {204 pitch: accelerometerPitch,205 roll: accelerometerRoll,206 x: accelerometerX,207 y: accelerometerY,208 z: accelerometerZ209 },210 objectTemp: {211 a: objectTemp1,212 b: objectTemp2,213 c: objectTemp3,214 d: objectTemp4,215 e: objectTemp1norm,216 f: objectTemp2norm,217 g: objectTemp3norm,218 h: objectTemp4norm219 },220 ambientTemp: {221 a: ambientAverage222 },223 proximityData: {224 a: proximity225 },226 batteryData: {227 a: batteryVoltage228 },229 detectionData: {230 a: deviceNN5,231 b: deviceNN7232 }233 }234 state = {235 orientation: data.orientation,236 accelerometer: data.accelerometer,237 objectTemp: data.objectTemp,238 ambientTemp: data.ambientTemp,239 proximityData: data.proximityData,240 battery: data.batteryData,241 deviceDetect: data.detectionData242 }243 //move this out of state change 244 if (sendCommandFlag) {245 //this.standardServer = server;246 for (var i = 0; i < 3; i++) {247 // sendControlService();248 _this.sendControlService([services.controlService, ], [characteristics.commandReadCharacteristic, characteristics.commandWriteCharacteristic, characteristics.deviceDataCharacteristic], _this.standardServer);249 }250 sendCommandFlag = false;251 }252 _this.onStateChangeCallback(state);253 }254 onStateChangeCallback() {}255 getdeviceData(service, characteristic, server) {256 return server.getPrimaryService(service.uuid)257 .then(newService => {258 console.log('getting characteristic: ', characteristic.name);259 return newService.getCharacteristic(characteristic.uuid)260 })261 .then(char => {262 char.startNotifications().then(res => {263 char.addEventListener('characteristicvaluechanged', _this.handleDeviceDataChanged);264 })265 })266 }267 onStateChange(callback) {268 _this.onStateChangeCallback = callback;269 }270}271/*******************************************************************************************************************272 *********************************************** INITIALIZE *********************************************************273 ********************************************************************************************************************/274//sensor array sample data275var sensorDataArray = new Array(18).fill(0);276var masterDataArray = new Array(42);277for (var i = 0; i < masterDataArray.length; i++) {278 masterDataArray[i] = new Array;279}280var batteryVoltage;281var selectedTargetNum = 0; //starting target number index282var selectedTargetName = "sh-r-eyes-select"; //starting target ID283//sensor array sample data FOR CUSTOM TRAINING284var NN1TrueDataArray = new Array;285var NN1FalseDataArray = new Array;286var NN2TrueDataArray = new Array;287var NN2FalseDataArray = new Array;288var NN1Architecture = 'none';289var NN2Architecture = 'none';290var NN1NumInputs = 5;291var NN2NumInputs = 7;292//master session data array of arrays293var sensorDataSession = [];294//which samples in the session data array are part of a particular sample set295var sessionSampleSetIndex = [];296var getSamplesFlag = 0;297var getSamplesTypeFlag = 0; //0=none 1=NN1T 2=NN1F 3=NN2T 4=NN2F298//do we have a trained NN to apply to live sensor data?299var haveNNFlag1 = false;300var trainNNFlag1 = false;301var activeNNFlag1 = false;302var haveNNFlag2 = false;303var trainNNFlag2 = false;304var activeNNFlag2 = false;305//stored MM models306var loadNNFlag = false;307var loadNNTargetSelect;308var loadNNData5 = new Array(500).fill(0);309var loadNNData7 = new Array(575).fill(0);310//NN scores311var scoreArray = new Array(1).fill(0);312var scoreArraySmooth = new Array(2);313scoreArraySmooth[0] = 0.5;314scoreArraySmooth[1] = 0.5;315var pastDataNN1 = new Array(5).fill(0.5);316var pastDataNN2 = new Array(5).fill(0.5);317var initialised = false;318var timeout = null;319$(document).ready(function() {320 /*******************************************************************************************************************321 *********************************************** WEB BLUETOOTH ******************************************************322 ********************************************************************************************************************/323 //Web Bluetooth connection button and ongoing device data update function324 button.onclick = function(e) {325 var sensorController = new ControllerWebBluetooth("Tingle");326 sensorController.connect();327 //ON SENSOR DATA UPDATE328 sensorController.onStateChange(function(state) {329 bluetoothDataFlag = true;330 });331 //check for new data every X milliseconds - this is to decouple execution from Web Bluetooth actions332 setInterval(function() {333 // bluetoothDataFlag = getBluetoothDataFlag();334 if (bluetoothDataFlag == true) {335 // state = getState();336 /* objectTempData = state.objectTemp;337 proximityData = state.proximityData;338 accelerometerData = state.accelerometer;339 ambientTempData = state.ambientTemp;340 heartRateData = state.heartRate; */341 timeStamp = new Date().getTime();342 //load data into global array343 sensorDataArray = new Array(18).fill(0);344 sensorDataArray[0] = state.objectTemp.a.toFixed(1);345 sensorDataArray[1] = state.objectTemp.b.toFixed(1);346 sensorDataArray[2] = state.objectTemp.c.toFixed(1);347 sensorDataArray[3] = state.objectTemp.d.toFixed(1);348 sensorDataArray[4] = state.proximityData.a.toFixed(1);349 sensorDataArray[5] = state.accelerometer.pitch.toFixed(1);350 sensorDataArray[6] = state.accelerometer.roll.toFixed(1);351 sensorDataArray[7] = state.accelerometer.x.toFixed(2);352 sensorDataArray[8] = state.accelerometer.y.toFixed(2);353 sensorDataArray[9] = state.accelerometer.z.toFixed(2);354 sensorDataArray[10] = state.ambientTemp.a.toFixed(2);355 sensorDataArray[11] = state.objectTemp.e.toFixed(4);356 sensorDataArray[12] = state.objectTemp.f.toFixed(4);357 sensorDataArray[13] = state.objectTemp.g.toFixed(4);358 sensorDataArray[14] = state.objectTemp.h.toFixed(4);359 sensorDataArray[15] = timeStamp;360 batteryVoltage = state.battery.a.toFixed(2);361 //update time series chart362 var rawThermo1Chart = ((sensorDataArray[0] - 76) / 24);363 var rawThermo2Chart = ((sensorDataArray[1] - 76) / 24);364 var rawThermo3Chart = ((sensorDataArray[2] - 76) / 24);365 var rawThermo4Chart = ((sensorDataArray[3] - 76) / 24);366 var rawPitchChart = (sensorDataArray[5] / 400);367 var rawRollChart = (sensorDataArray[6] / 400);368 var rawProximityChart = (sensorDataArray[4] / 270);369 //sensor values in bottom 2/3 of chart , 1/10 height each370 rawThermo1Chart = (rawThermo1Chart / 4.5) + 5.5 * 0.1;371 rawThermo2Chart = (rawThermo2Chart / 4.5) + 5 * 0.1;372 rawThermo3Chart = (rawThermo3Chart / 4.5) + 4.5 * 0.1;373 rawThermo4Chart = (rawThermo4Chart / 4.5) + 4 * 0.1;374 rawPitchChart = (rawPitchChart / 7) + 3 * 0.1;375 rawRollChart = (rawRollChart / 7) + 2 * 0.1;376 rawProximityChart = (rawProximityChart / 10) + 1 * 0.1;377 lineThermo1.append(timeStamp, rawThermo1Chart);378 lineThermo2.append(timeStamp, rawThermo2Chart);379 lineThermo3.append(timeStamp, rawThermo3Chart);380 lineThermo4.append(timeStamp, rawThermo4Chart);381 linePitch.append(timeStamp, rawPitchChart);382 lineRoll.append(timeStamp, rawRollChart);383 lineProximity.append(timeStamp, rawProximityChart);384 //if data sample collection has been flagged385 // getSensorData();386 if (getSamplesFlag > 0) {387 collectData();388 } else if (trainNNFlag1 || trainNNFlag2) {389 //don't do anything390 } else {391 if (haveNNFlag1 && activeNNFlag1) { //we have a NN and we want to apply to current sensor data392 getNNScore(1);393 } else if( loadNNFlag ){ //run loaded model394 getNNScore(1);395 }396 if (haveNNFlag2 && activeNNFlag2) { //we have a NN and we want to apply to current sensor data397 getNNScore(2);398 } else if( loadNNFlag ){ //run loaded model399 getNNScore(2);400 } 401 }402 displayData();403 bluetoothDataFlag = false;404 }405 }, 200); // throttle 100 = 10Hz limit406 }407 /*******************************************************************************************************************408 **************************************** STREAMING SENSOR DATA CHART ***********************************************409 *******************************************************************************************************************/410 //add smoothie.js time series streaming data chart411 var chartHeight = 100;412 var chartWidth = $(window).width();413 $("#streaming-data-chart").html('<canvas id="chart-canvas" width="' + chartWidth + '" height="' + chartHeight + '"></canvas>');414 var streamingChart = new SmoothieChart({/* grid: { strokeStyle:'rgb(125, 0, 0)', fillStyle:'rgb(60, 0, 0)', lineWidth: 1, millisPerLine: 250, verticalSections: 6, }, labels: { fillStyle:'rgb(60, 0, 0)' } */ });415streamingChart.streamTo(document.getElementById("chart-canvas"), 350 /*delay*/ );416 var lineThermo1 = new TimeSeries();417 var lineThermo2 = new TimeSeries();418 var lineThermo3 = new TimeSeries();419 var lineThermo4 = new TimeSeries();420 var linePitch = new TimeSeries();421 var lineRoll = new TimeSeries();422 var lineProximity = new TimeSeries();423 var lineNN1 = new TimeSeries();424 var lineNN2 = new TimeSeries();425 var lineNN1Smooth = new TimeSeries();426 var lineNN2Smooth = new TimeSeries();427 var lineNN1Var = new TimeSeries();428 var lineNN2Var = new TimeSeries();429 var lineNNAv = new TimeSeries();430 streamingChart.addTimeSeries(lineThermo1, {431 strokeStyle: 'rgb(133, 87, 35)',432 lineWidth: 3433 });434 streamingChart.addTimeSeries(lineThermo2, {435 strokeStyle: 'rgb(185, 156, 107)',436 lineWidth: 3437 });438 streamingChart.addTimeSeries(lineThermo3, {439 strokeStyle: 'rgb(143, 59, 27)',440 lineWidth: 3441 });442 streamingChart.addTimeSeries(lineThermo4, {443 strokeStyle: 'rgb(213, 117, 0)',444 lineWidth: 3445 });446 streamingChart.addTimeSeries(linePitch, {447 strokeStyle: 'rgb(128, 128, 128)',448 lineWidth: 3449 });450 streamingChart.addTimeSeries(lineRoll, {451 strokeStyle: 'rgb(240, 240, 240)',452 lineWidth: 3453 });454 streamingChart.addTimeSeries(lineProximity, {455 strokeStyle: 'rgb(128, 128, 255)',456 lineWidth: 3457 });458 streamingChart.addTimeSeries(lineNN1, {459 strokeStyle: 'rgb(72, 244, 68)',460 lineWidth: 4461 });462 streamingChart.addTimeSeries(lineNN2, {463 strokeStyle: 'rgb(244, 66, 66)',464 lineWidth: 4465 });466 streamingChart.addTimeSeries(lineNN1Smooth, {467 strokeStyle: 'rgb(58, 230, 54)',468 lineWidth: 3469 });470 streamingChart.addTimeSeries(lineNN2Smooth, {471 strokeStyle: 'rgb(230, 52, 52)',472 lineWidth: 3473 });474 streamingChart.addTimeSeries(lineNN1Var, {475 strokeStyle: 'rgb(38, 210, 32)',476 lineWidth: 3477 });478 streamingChart.addTimeSeries(lineNN2Var, {479 strokeStyle: 'rgb(210, 30, 30)',480 lineWidth: 3481 });482 streamingChart.addTimeSeries(lineNNAv, {483 strokeStyle: 'rgb(255, 0, 255)',484 lineWidth: 4485 });486 //min/max streaming chart button487 $('#circleDrop').click(function() {488 $('.card-middle').slideToggle();489 $('.close').toggleClass('closeRotate');490 var chartHeight = $(window).height() / 1.2;491 var chartWidth = $(window).width();492 if ($("#chart-size-button").hasClass('closeRotate')) {493 $("#streaming-data-chart").html('<canvas id="chart-canvas" width="' + chartWidth + '" height="' + chartHeight + '"></canvas>');494 } else {495 $("#streaming-data-chart").html('<canvas id="chart-canvas" width="' + chartWidth + '" height="' + 100 + '"></canvas>');496 }497 //hide controls498 $("#basic-interface-container, #hand-head-ui-container, #nn-slide-controls, .console, #interface-controls, #dump-print, #record-controls").toggleClass("hide-for-chart");499 //redraw chart500 streamingChart.streamTo(document.getElementById("chart-canvas"), 350 /*delay*/ );501 });502 function displayData() {503 var objectTempElement1 = document.getElementsByClassName('object-temp-1-data')[0];504 objectTempElement1.innerHTML = sensorDataArray[0];505 var objectTempElement2 = document.getElementsByClassName('object-temp-2-data')[0];506 objectTempElement2.innerHTML = sensorDataArray[1];507 var objectTempElement3 = document.getElementsByClassName('object-temp-3-data')[0];508 objectTempElement3.innerHTML = sensorDataArray[2];509 var objectTempElement4 = document.getElementsByClassName('object-temp-4-data')[0];510 objectTempElement4.innerHTML = sensorDataArray[3];511 var proximityElement = document.getElementsByClassName('proximity-data')[0];512 proximityElement.innerHTML = sensorDataArray[4];513 var accelerometerPitchDiv = document.getElementsByClassName('accelerometer-pitch-data')[0];514 accelerometerPitchDiv.innerHTML = sensorDataArray[5];515 var accelerometerRollDiv = document.getElementsByClassName('accelerometer-roll-data')[0];516 accelerometerRollDiv.innerHTML = sensorDataArray[6];517 var accelerometerXElement = document.getElementsByClassName('accelerometer-x-data')[0];518 accelerometerXElement.innerHTML = sensorDataArray[7];519 var accelerometerYElement = document.getElementsByClassName('accelerometer-y-data')[0];520 accelerometerYElement.innerHTML = sensorDataArray[8];521 var accelerometerZElement = document.getElementsByClassName('accelerometer-z-data')[0];522 accelerometerZElement.innerHTML = sensorDataArray[9];523 var ambientTempAverageElement = document.getElementsByClassName('ambient-temp-average-data')[0];524 ambientTempAverageElement.innerHTML = sensorDataArray[10];525 var batteryDataElement = document.getElementsByClassName('battery-data')[0];526 batteryDataElement.innerHTML = batteryVoltage;527 }528 function updateSampleCountDisplay() {529 $('.message-nn1-true').html(NN1TrueDataArray.length);530 $('.message-nn1-false').html(NN1FalseDataArray.length);531 $('.message-nn2-true').html(NN2TrueDataArray.length);532 $('.message-nn2-false').html(NN2FalseDataArray.length);533 }534 /**********************************************************************************************************535 ********************************** COLLECT SENSOR DATA ***************************************************536 **********************************************************************************************************/537 function collectData() {538 var collectedDataArray = new Array(18).fill(0); //12 device 539 collectedDataArray = sensorDataArray;540 console.log("web bluetooth sensor data:");541 console.dir(collectedDataArray);542 //add sample to set543 sensorDataSession.push(collectedDataArray);544 //add to master545 masterDataArray[selectedTargetNum].push(sensorDataArray);546 $( "span[data='" + selectedTargetNum + "']" ).html(masterDataArray[selectedTargetNum].length);547 if (getSamplesTypeFlag == 1) {548 //add to master549 // masterDataArray[selectedTargetNum].push(collectedDataArray);550 // $( "span[data='" + selectedTargetNum + "']" ).html(masterDataArray[selectedTargetNum].length);551 NN1TrueDataArray.push(collectedDataArray);552 $('.message-nn1-true').html(NN1TrueDataArray.length);553 } else if (getSamplesTypeFlag == 2) {554 NN1FalseDataArray.push(collectedDataArray);555 $('.message-nn1-false').html(NN1FalseDataArray.length);556 } else if (getSamplesTypeFlag == 3) {557 NN2TrueDataArray.push(collectedDataArray);558 $('.message-nn2-true').html(NN2TrueDataArray.length);559 } else if (getSamplesTypeFlag == 4) {560 NN2FalseDataArray.push(collectedDataArray);561 $('.message-nn2-false').html(NN2FalseDataArray.length);562 }563 console.log("Set Index: ");564 console.dir(sessionSampleSetIndex);565 //countdown for data collection566 getSamplesFlag = getSamplesFlag - 1;567 }568 /*******************************************************************************************************************569 *********************************************** NEURAL NETWORKS ****************************************************570 ********************************************************************************************************************/571 /**572 * Attach synaptic neural net components to app object573 */574 var nnRate = $("#rate-input").val();575 var nnIterations = $("#iterations-input").val();576 var nnError = $("#error-input").val();577 // ************** NEURAL NET #1578 var Neuron = synaptic.Neuron;579 var Layer = synaptic.Layer;580 var Network = synaptic.Network;581 var Trainer = synaptic.Trainer;582 var Architect = synaptic.Architect;583 var neuralNet = new Architect.LSTM(5, 5, 2, 1);584 var trainer = new Trainer(neuralNet);585 var trainingData;586 // ************* NEURAL NET #2587 var Neuron2 = synaptic.Neuron;588 var Layer2 = synaptic.Layer;589 var Network2 = synaptic.Network;590 var Trainer2 = synaptic.Trainer;591 var Architect2 = synaptic.Architect;592 var neuralNet2 = new Architect2.LSTM(7, 5, 2, 1);593 var trainer2 = new Trainer2(neuralNet2);594 var trainingData2;595 /**********************************************************************************************************596 ********************************** GET NEURAL NETWORK MODEL SCORE *****************************************597 **********************************************************************************************************/598 function getNNScore(selectNN) {599 var scoreArray = new Array(1).fill(0);600 var timeStamp = new Date().getTime();601 var displayScore;602 if (selectNN == 1) {603 var feedArray = new Array(5).fill(0);604 if(preProcess == 1){605 feedArray[0] = sensorDataArray[0] / 101;606 feedArray[1] = sensorDataArray[1] / 101;607 feedArray[2] = sensorDataArray[2] / 101;608 feedArray[3] = sensorDataArray[3] / 101; 609 } else if(preProcess == 2) {610 feedArray[0] = (sensorDataArray[0] - 69) / (101 - 69);611 feedArray[1] = (sensorDataArray[1] - 69) / (101 - 69);612 feedArray[2] = (sensorDataArray[2] - 69) / (101 - 69);613 feedArray[3] = (sensorDataArray[3] - 69) / (101 - 69);614 } else if(preProcess == 3) {615 feedArray[0] = sensorDataArray[11];616 feedArray[1] = sensorDataArray[12];617 feedArray[2] = sensorDataArray[13];618 feedArray[3] = sensorDataArray[14]; 619 } else if(preProcess == 4) {620 var thermSampAv = ( (parseFloat(sensorDataArray[0]) - 69) + (parseFloat(sensorDataArray[1]) - 69) + (parseFloat(sensorDataArray[2]) - 69) + (parseFloat(sensorDataArray[3]) - 69)) / 4;621 feedArray[0] = (sensorDataArray[0] - 69) / thermSampAv - 0.5;622 feedArray[1] = (sensorDataArray[1] - 69) / thermSampAv - 0.5;623 feedArray[2] = (sensorDataArray[2] - 69) / thermSampAv - 0.5;624 feedArray[3] = (sensorDataArray[3] - 69) / thermSampAv - 0.5; 625 } else if(preProcess == 5) {626 var thermSampMin = Math.min( parseFloat(sensorDataArray[0]), Math.min( parseFloat(sensorDataArray[1]), Math.min( parseFloat(sensorDataArray[2]), parseFloat(sensorDataArray[3]) ) ) );627 feedArray[0] = (sensorDataArray[0] - 69) / (thermSampMin - 69);628 feedArray[1] = (sensorDataArray[1] - 69) / (thermSampMin - 69);629 feedArray[2] = (sensorDataArray[2] - 69) / (thermSampMin - 69);630 feedArray[3] = (sensorDataArray[3] - 69) / (thermSampMin - 69);631 }632 feedArray[4] = sensorDataArray[4] / 250;633 // use trained NN or loaded NN634 if (haveNNFlag1 && activeNNFlag1) {635 scoreArray = neuralNet.activate(feedArray); //RUN TRAINED NN MODEL636 } else if (loadNNFlag) {637 scoreArray = runStoredModel5(feedArray); //RUN STORED NN MODEL638 }639 console.log("NN1 FEED ARRAY: " + feedArray);640 console.log("NN1 SCORE ARRAY: " + scoreArray);641 displayScore = scoreArray[0].toFixed(4) * 100;642 displayScore = displayScore.toFixed(2);643 $(".message-nn1-score").html(displayScore + '%');644 var rawLineNN1Chart = scoreArray[0].toFixed(4);645 rawLineNN1Chart = (rawLineNN1Chart / 2) + 0.7;646 lineNN1.append(timeStamp, rawLineNN1Chart);647 //RUNNING AVERAGE648 scoreArraySmooth[0] = (parseFloat(scoreArraySmooth[0]) + parseFloat(scoreArray[0]) ) / 2;649 var rawLineNN1ChartSmooth = scoreArraySmooth[0].toFixed(4);650 rawLineNN1ChartSmooth = (rawLineNN1ChartSmooth / 2) + 0.7;651 lineNN1Smooth.append(timeStamp, rawLineNN1ChartSmooth);652 console.log("rawLineNN1ChartSmooth: " + rawLineNN1ChartSmooth);653 //VARIANCE654 //update historical data and calcualte average655 var NN1Av = 0;656 for(var j = 0; j < 4; j++){ 657 pastDataNN1[j] = pastDataNN1[j + 1]; 658 NN1Av = NN1Av + pastDataNN1[j + 1];659 }660 pastDataNN1[4] = parseFloat(scoreArray[0]);661 NN1Av = (NN1Av + pastDataNN1[4]) / 5;662 //calculate variance663 var NN1Var = 0;664 for(var k = 0; k < 5; k++){ 665 NN1Var = NN1Var + Math.abs(NN1Av - pastDataNN1[k]);666 }667 NN1Var = NN1Var / 5;668 lineNN1Var.append(timeStamp, NN1Var);669 console.log("NN1 Variance: " + (NN1Var * 100));670 } else if (selectNN == 2) {671 var feedArray = new Array(7).fill(0);672 if(preProcess == 1){673 feedArray[0] = sensorDataArray[0] / 101;674 feedArray[1] = sensorDataArray[1] / 101;675 feedArray[2] = sensorDataArray[2] / 101;676 feedArray[3] = sensorDataArray[3] / 101; 677 } else if(preProcess == 2) {678 feedArray[0] = (sensorDataArray[0] - 69) / (101 - 69);679 feedArray[1] = (sensorDataArray[1] - 69) / (101 - 69);680 feedArray[2] = (sensorDataArray[2] - 69) / (101 - 69);681 feedArray[3] = (sensorDataArray[3] - 69) / (101 - 69);682 } else if(preProcess == 3) {683 feedArray[0] = sensorDataArray[11];684 feedArray[1] = sensorDataArray[12];685 feedArray[2] = sensorDataArray[13];686 feedArray[3] = sensorDataArray[14]; 687 } else if(preProcess == 4) {688 var thermSampAv = ( (parseFloat(sensorDataArray[0]) - 69) + (parseFloat(sensorDataArray[1]) - 69) + (parseFloat(sensorDataArray[2]) - 69) + (parseFloat(sensorDataArray[3]) - 69)) / 4;689 feedArray[0] = (sensorDataArray[0] - 69) / thermSampAv - 0.5;690 feedArray[1] = (sensorDataArray[1] - 69) / thermSampAv - 0.5;691 feedArray[2] = (sensorDataArray[2] - 69) / thermSampAv - 0.5;692 feedArray[3] = (sensorDataArray[3] - 69) / thermSampAv - 0.5; 693 } else if(preProcess == 5) {694 var thermSampMin = Math.min( parseFloat(sensorDataArray[0]), Math.min( parseFloat(sensorDataArray[1]), Math.min( parseFloat(sensorDataArray[2]), parseFloat(sensorDataArray[3]) ) ) );695 feedArray[0] = (sensorDataArray[0] - 69) / (thermSampMin - 69);696 feedArray[1] = (sensorDataArray[1] - 69) / (thermSampMin - 69);697 feedArray[2] = (sensorDataArray[2] - 69) / (thermSampMin - 69);698 feedArray[3] = (sensorDataArray[3] - 69) / (thermSampMin - 69);699 }700 feedArray[4] = sensorDataArray[4] / 250;701 feedArray[5] = sensorDataArray[5] / 360;702 feedArray[6] = sensorDataArray[6] / 360;703 if (haveNNFlag2 && activeNNFlag2) {704 scoreArray = neuralNet2.activate(feedArray); //RUN TRAINED NN MODEL705 } else if (loadNNFlag) {706 scoreArray = runStoredModel7(feedArray); //RUN STORED NN MODEL707 }708 console.log("NN2 FEED ARRAY: " + feedArray);709 console.log("NN2 SCORE ARRAY: " + scoreArray);710 displayScore = scoreArray[0].toFixed(4) * 100;711 displayScore = displayScore.toFixed(2);712 $(".message-nn2-score").html(displayScore + '%');713 var rawLineNN2Chart = scoreArray[0].toFixed(4);714 rawLineNN2Chart = (rawLineNN2Chart / 2) + 0.7;715 lineNN2.append(timeStamp, rawLineNN2Chart);716 //RUNNING AVERAGE717 scoreArraySmooth[1] = ( parseFloat(scoreArraySmooth[1]) + parseFloat(scoreArraySmooth[1]) + parseFloat(scoreArray[0]) ) / 3;718 var rawLineNN2ChartSmooth = scoreArraySmooth[1].toFixed(4);719 rawLineNN2ChartSmooth = (rawLineNN2ChartSmooth / 2) + 0.7;720 lineNN2Smooth.append(timeStamp, rawLineNN2ChartSmooth);721 console.log("rawLineNN2ChartSmooth: " + rawLineNN2ChartSmooth);722 //VARIANCE723 //update historical data and calcualte average724 var NN2Av = 0;725 for(var j = 0; j < 4; j++){ 726 pastDataNN2[j] = pastDataNN2[j + 1]; 727 NN2Av = NN2Av + pastDataNN2[j + 1];728 }729 pastDataNN2[4] = parseFloat(scoreArray[0]);730 NN2Av = (NN2Av + pastDataNN2[4]) / 5;731 //calculate variance732 var NN2Var = 0;733 for(var k = 0; k < 5; k++){ 734 NN2Var = NN2Var + Math.abs(NN2Av - pastDataNN2[k]);735 }736 NN2Var = NN2Var / 5;737 lineNN2Var.append(timeStamp, NN2Var);738 console.log("NN2 Variance: " + (NN2Var * 100));739 //PLOT AVERAGE OF NN1 and NN2740 var rawLineNNAv = ( parseFloat(scoreArraySmooth[0]) + parseFloat(scoreArraySmooth[1]) ) / 2;741 rawLineNNAv = (rawLineNNAv / 2) + 0.7;742 lineNNAv.append(timeStamp, rawLineNNAv);743 }744 }745 /**********************************************************************************************************746 ********************************** TRAIN NEURAL NETWORK MODEL *********************************************747 **********************************************************************************************************/748 function trainNN(selectNN) {749 //'5:2:1', '5:5:1', '5:5:2:1', '5:5:5:1', '7:2:1', '7:7:1', '7:7:2:1', '7:7:7:1'750 // var processedDataSession = sensorDataSession;751 var processedDataSession = new Array;752 var falseDataArray = new Array;753 var trueDataArray = new Array;754 trainingData = new Array;755 trainingData2 = new Array;756 nnRate = $("#rate-input").val();757 nnIterations = $("#iterations-input").val();758 nnError = $("#error-input").val();759 /* if (selectNN == 1) {760 trueDataArray = NN1TrueDataArray;761 falseDataArray = NN1FalseDataArray;762 } else if (selectNN == 2) {763 trueDataArray = NN2TrueDataArray;764 falseDataArray = NN2FalseDataArray;765 } */766 /* cycle the position text field inputs */767 console.log("***FINDING DATA TO TRAIN AGAINST***");768 $( ".target-select-text" ).each(function() {769 var positionSelectedSampleTotal = parseInt( $( this ).val() );770 var falseSelectElementID = $(this).attr("id"); 771 console.log(falseSelectElementID + " : " + positionSelectedSampleTotal);772 if(positionSelectedSampleTotal > 0){773 var falseSelectElementIndex = parseInt( $(this).attr("num") );774 // var falseSelectElementID = parseInt( $(this).attr("id") );775 var falseSelectLength = masterDataArray[falseSelectElementIndex].length;776 console.log("** " + positionSelectedSampleTotal + " SAMPLES FROM " + falseSelectElementID);777 console.log("false select length: " + falseSelectLength);778 //asking for more data than exists779 if(positionSelectedSampleTotal >= falseSelectLength){780 for(var j = 0; j < falseSelectLength; j++){781 falseDataArray.push(masterDataArray[falseSelectElementIndex][j]);782 }783 } else {784 /* var j=0;785 while(j < positionSelectedSampleTotal){786 var oneQuartPlace = Math.round( (falseSelectLength / 4) * 1) + j - 1; //get data from different places787 var midPlace = Math.round( (falseSelectLength / 4) * 2) + j - 1;788 var threeQuartPlace = Math.round( (falseSelectLength / 4) * 3) + j - 1;789 console.log("quarter place:" + oneQuartPlace + " half place:" + midPlace + " three quarter place:" + threeQuartPlace);790 if(j < positionSelectedSampleTotal){ falseDataArray.push(masterDataArray[falseSelectElementIndex][j]); j++;791 792 if(j < positionSelectedSampleTotal && oneQuartPlace < falseSelectLength){ falseDataArray.push(masterDataArray[falseSelectElementIndex][oneQuartPlace]); j++; 793 794 if(j < positionSelectedSampleTotal && midPlace < falseSelectLength){ falseDataArray.push(masterDataArray[falseSelectElementIndex][midPlace]); j++; 795 if(j < positionSelectedSampleTotal && threeQuartPlace < falseSelectLength){ falseDataArray.push(masterDataArray[falseSelectElementIndex][threeQuartPlace]); j++; }796 }797 }798 }799 } */800 var trackRandom = new Array(2000).fill(0);801 var countFalseSamples = 0;802 while(countFalseSamples < positionSelectedSampleTotal){803 //random sample in target position array of samples804 var randomSampleIndex = Math.floor(Math.random() * falseSelectLength) + 1;805 //make sure we haven't used this data point yet806 if(trackRandom[(randomSampleIndex - 1)] == 0){807 falseDataArray.push(masterDataArray[falseSelectElementIndex][(randomSampleIndex - 1)]);808 //done with that sample, make note in tracking array809 trackRandom[(randomSampleIndex - 1)] = 1;810 countFalseSamples++;811 }812 }813 }814 }815 });816 console.log("TRAINING AGAINST " + falseDataArray.length + " SAMPLES");817 console.log("FALSE DATA: " + falseDataArray);818 //true data is currently selected target819 trueDataArray = masterDataArray[selectedTargetNum];820 //ADD DUPLICATE TRUE DATA IF MORE FALSE DATA THAN TRUE DATA821 var trueDataCounter = 0;822 while(falseDataArray.length > trueDataArray.length){823 trueDataArray.push(masterDataArray[selectedTargetNum][trueDataCounter]);824 trueDataCounter++;825 if(trueDataCounter > (masterDataArray[selectedTargetNum].length - 1)) trueDataCounter = 0;826 }827 console.log("TRAINING FOR " + trueDataArray.length + "TARGET SAMPLES");828 //combine true and false data829 var addSample = new Array(18).fill(0);830 for (var j = 0; j < trueDataArray.length; j++) {831 addSample = trueDataArray[j];832 addSample[17] = 1; //true833 processedDataSession.push(addSample);834 }835 for (var k = 0; k < falseDataArray.length; k++) {836 addSample = falseDataArray[k];837 addSample[17] = 0; //false838 processedDataSession.push(addSample);839 }840 neuralNet = new Architect.LSTM(5, 5, 2, 1);841 trainer = new Trainer(neuralNet);842 neuralNet2 = new Architect.LSTM(7, 5, 2, 1);843 trainer2 = new Trainer2(neuralNet2);844 for (var i = 0; i < processedDataSession.length; i++) {845 var currentSample = processedDataSession[i];846 var outputArray = new Array(1).fill(0);847 outputArray[0] = currentSample[17]; //true or false848 var inputArray = new Array(5).fill(0);849 if(preProcess == 1){850 inputArray[0] = currentSample[0] / 101;851 inputArray[1] = currentSample[1] / 101;852 inputArray[2] = currentSample[2] / 101;853 inputArray[3] = currentSample[3] / 101; 854 } else if(preProcess == 2) {855 inputArray[0] = (currentSample[0] - 69) / (101 - 69);856 inputArray[1] = (currentSample[1] - 69) / (101 - 69);857 inputArray[2] = (currentSample[2] - 69) / (101 - 69);858 inputArray[3] = (currentSample[3] - 69) / (101 - 69);859 } else if(preProcess == 3) {860 inputArray[0] = currentSample[11];861 inputArray[1] = currentSample[12];862 inputArray[2] = currentSample[13];863 inputArray[3] = currentSample[14]; 864 } else if(preProcess == 4) {865 var thermSampAv = ( (parseFloat(currentSample[0]) - 69) + (parseFloat(currentSample[1]) - 69) + (parseFloat(currentSample[2]) - 69) + (parseFloat(currentSample[3]) - 69) ) / 4;866 console.log("average for norm: " + thermSampAv);867 inputArray[0] = ( (currentSample[0] - 69) / thermSampAv) - 0.5;868 inputArray[1] = ( (currentSample[1] - 69) / thermSampAv) - 0.5;869 inputArray[2] = ( (currentSample[2] - 69) / thermSampAv) - 0.5;870 inputArray[3] = ( (currentSample[3] - 69) / thermSampAv) - 0.5; 871 } else if(preProcess == 5) {872 var thermSampMin = Math.min( parseFloat(currentSample[0]), Math.min( parseFloat(currentSample[1]), Math.min( parseFloat(currentSample[2]), parseFloat(currentSample[3]) ) ) );873 inputArray[0] = (currentSample[0] - 69) / (thermSampMin - 69);874 inputArray[1] = (currentSample[1] - 69) / (thermSampMin - 69);875 inputArray[2] = (currentSample[2] - 69) / (thermSampMin - 69);876 inputArray[3] = (currentSample[3] - 69) / (thermSampMin - 69);877 }878 inputArray[4] = currentSample[4] / 250;879 var inputArray2 = new Array(7).fill(0);880 if(preProcess == 1){881 inputArray2[0] = currentSample[0] / 101;882 inputArray2[1] = currentSample[1] / 101;883 inputArray2[2] = currentSample[2] / 101;884 inputArray2[3] = currentSample[3] / 101; 885 } else if(preProcess == 2) {886 inputArray2[0] = (currentSample[0] - 69) / (101 - 69);887 inputArray2[1] = (currentSample[1] - 69) / (101 - 69);888 inputArray2[2] = (currentSample[2] - 69) / (101 - 69);889 inputArray2[3] = (currentSample[3] - 69) / (101 - 69);890 } else if(preProcess == 3) {891 inputArray2[0] = currentSample[11];892 inputArray2[1] = currentSample[12];893 inputArray2[2] = currentSample[13];894 inputArray2[3] = currentSample[14]; 895 } else if(preProcess == 4) {896 var thermSampAv = ( (parseFloat(currentSample[0]) - 69) + (parseFloat(currentSample[1]) - 69) + (parseFloat(currentSample[2]) - 69) + (parseFloat(currentSample[3]) - 69)) / 4;897 inputArray2[0] = ( (currentSample[0] - 69) / thermSampAv) - 0.5;898 inputArray2[1] = ( (currentSample[1] - 69) / thermSampAv) - 0.5;899 inputArray2[2] = ( (currentSample[2] - 69) / thermSampAv) - 0.5;900 inputArray2[3] = ( (currentSample[3] - 69) / thermSampAv) - 0.5; 901 } else if(preProcess == 5) {902 var thermSampMin = Math.min( parseFloat(currentSample[0]), Math.min( parseFloat(currentSample[1]), Math.min( parseFloat(currentSample[2]), parseFloat(currentSample[3]) ) ) );903 inputArray2[0] = (currentSample[0] - 69) / (thermSampMin - 69);904 inputArray2[1] = (currentSample[1] - 69) / (thermSampMin - 69);905 inputArray2[2] = (currentSample[2] - 69) / (thermSampMin - 69);906 inputArray2[3] = (currentSample[3] - 69) / (thermSampMin - 69);907 }908 inputArray2[4] = currentSample[4] / 250;909 inputArray2[5] = currentSample[5] / 360;910 inputArray2[6] = currentSample[6] / 360;911 trainingData.push({912 input: inputArray,913 output: outputArray914 });915 trainingData2.push({916 input: inputArray2,917 output: outputArray918 });919 console.log(currentSample + " TRAINING INPUT: " + inputArray + " --> NN# " + selectNN);920 console.log(currentSample + " TRAINING OUTPUT: " + outputArray + " --> NN# " + selectNN);921 }922 console.log("TRAINING ON selectNN1 --> interations:" + nnIterations + " error:" + nnError + " rate:" + nnRate);923 trainer.train(trainingData, {924 rate: nnRate,925 iterations: nnIterations,926 error: nnError,927 shuffle: true,928 log: 5,929 cost: Trainer.cost.CROSS_ENTROPY930 });931 //we have a trained NN to use932 haveNNFlag1 = true;933 trainNNFlag1 = false;934 $('#activate-btn').addClass("haveNN");935 $('#export-btn').addClass("haveNN");936 console.log("TRAINING ON selectNN2");937 trainer2.train(trainingData2, {938 rate: nnRate,939 iterations: nnIterations,940 error: nnError,941 shuffle: true,942 log: 5,943 cost: Trainer2.cost.CROSS_ENTROPY944 });945 //we have a trained NN to use946 haveNNFlag2 = true;947 trainNNFlag2 = false;948 $('#activate2-btn').addClass("haveNN");949 $('#export2-btn').addClass("haveNN");950 }951 952 /********************************************************************************************************************953 *********************************************** RUN STORED MODEL ****************************************************954 ********************************************************************************************************************/955 function runStoredModel5(feedArray){956 var output = [];957 var F1 = loadNNData5;958 F1[3] = feedArray[0];959 F1[5] = feedArray[1];960 F1[7] = feedArray[2];961 F1[9] = feedArray[3];962 F1[11] = feedArray[4];963 F1[0] = F1[1];F1[1] = F1[2];F1[1] += F1[3] * F1[4];F1[1] += F1[5] * F1[6];F1[1] += F1[7] * F1[8];F1[1] += F1[9] * F1[10];F1[1] += F1[11] * F1[12];F1[1] += F1[13] * F1[14];F1[1] += F1[15] * F1[16];F1[1] += F1[17] * F1[18];F1[1] += F1[19] * F1[20];F1[1] += F1[21] * F1[22];F1[23] = (1 / (1 + Math.exp(-F1[1])));F1[24] = F1[23] * (1 - F1[23]);F1[25] = F1[23];F1[26] = F1[23];F1[27] = F1[23];F1[28] = F1[23];F1[29] = F1[23];964 F1[30] = F1[31];F1[31] = F1[32];F1[31] += F1[3] * F1[33];F1[31] += F1[5] * F1[34];F1[31] += F1[7] * F1[35];F1[31] += F1[9] * F1[36];F1[31] += F1[11] * F1[37];F1[31] += F1[13] * F1[38];F1[31] += F1[15] * F1[39];F1[31] += F1[17] * F1[40];F1[31] += F1[19] * F1[41];F1[31] += F1[21] * F1[42];F1[43] = (1 / (1 + Math.exp(-F1[31])));F1[44] = F1[43] * (1 - F1[43]);F1[45] = F1[43];F1[46] = F1[43];F1[47] = F1[43];F1[48] = F1[43];F1[49] = F1[43];965 F1[50] = F1[51];F1[51] = F1[52];F1[51] += F1[3] * F1[53];F1[51] += F1[5] * F1[54];F1[51] += F1[7] * F1[55];F1[51] += F1[9] * F1[56];F1[51] += F1[11] * F1[57];F1[51] += F1[13] * F1[58];F1[51] += F1[15] * F1[59];F1[51] += F1[17] * F1[60];F1[51] += F1[19] * F1[61];F1[51] += F1[21] * F1[62];F1[63] = (1 / (1 + Math.exp(-F1[51])));F1[64] = F1[63] * (1 - F1[63]);F1[65] = F1[63];F1[66] = F1[63];F1[67] = F1[63];F1[68] = F1[63];F1[69] = F1[63];966 F1[70] = F1[71];F1[71] = F1[72];F1[71] += F1[3] * F1[73];F1[71] += F1[5] * F1[74];F1[71] += F1[7] * F1[75];F1[71] += F1[9] * F1[76];F1[71] += F1[11] * F1[77];F1[71] += F1[13] * F1[78];F1[71] += F1[15] * F1[79];F1[71] += F1[17] * F1[80];F1[71] += F1[19] * F1[81];F1[71] += F1[21] * F1[82];F1[83] = (1 / (1 + Math.exp(-F1[71])));F1[84] = F1[83] * (1 - F1[83]);F1[85] = F1[83];F1[86] = F1[83];F1[87] = F1[83];F1[88] = F1[83];F1[89] = F1[83];967 F1[90] = F1[91];F1[91] = F1[92];F1[91] += F1[3] * F1[93];F1[91] += F1[5] * F1[94];F1[91] += F1[7] * F1[95];F1[91] += F1[9] * F1[96];F1[91] += F1[11] * F1[97];F1[91] += F1[13] * F1[98];F1[91] += F1[15] * F1[99];F1[91] += F1[17] * F1[100];F1[91] += F1[19] * F1[101];F1[91] += F1[21] * F1[102];F1[103] = (1 / (1 + Math.exp(-F1[91])));F1[104] = F1[103] * (1 - F1[103]);F1[105] = F1[103];F1[106] = F1[103];F1[107] = F1[103];F1[108] = F1[103];F1[109] = F1[103];968 F1[110] = F1[111];F1[111] = F1[112];F1[111] += F1[3] * F1[113];F1[111] += F1[5] * F1[114];F1[111] += F1[7] * F1[115];F1[111] += F1[9] * F1[116];F1[111] += F1[11] * F1[117];F1[111] += F1[13] * F1[118];F1[111] += F1[15] * F1[119];F1[111] += F1[17] * F1[120];F1[111] += F1[19] * F1[121];F1[111] += F1[21] * F1[122];F1[123] = (1 / (1 + Math.exp(-F1[111])));F1[124] = F1[123] * (1 - F1[123]);F1[125] = F1[123];969 F1[126] = F1[127];F1[127] = F1[128];F1[127] += F1[3] * F1[129];F1[127] += F1[5] * F1[130];F1[127] += F1[7] * F1[131];F1[127] += F1[9] * F1[132];F1[127] += F1[11] * F1[133];F1[127] += F1[13] * F1[134];F1[127] += F1[15] * F1[135];F1[127] += F1[17] * F1[136];F1[127] += F1[19] * F1[137];F1[127] += F1[21] * F1[138];F1[139] = (1 / (1 + Math.exp(-F1[127])));F1[140] = F1[139] * (1 - F1[139]);F1[141] = F1[139];970 F1[142] = F1[143];F1[143] = F1[144];F1[143] += F1[3] * F1[145];F1[143] += F1[5] * F1[146];F1[143] += F1[7] * F1[147];F1[143] += F1[9] * F1[148];F1[143] += F1[11] * F1[149];F1[143] += F1[13] * F1[150];F1[143] += F1[15] * F1[151];F1[143] += F1[17] * F1[152];F1[143] += F1[19] * F1[153];F1[143] += F1[21] * F1[154];F1[155] = (1 / (1 + Math.exp(-F1[143])));F1[156] = F1[155] * (1 - F1[155]);F1[157] = F1[155];971 F1[158] = F1[159];F1[159] = F1[160];F1[159] += F1[3] * F1[161];F1[159] += F1[5] * F1[162];F1[159] += F1[7] * F1[163];F1[159] += F1[9] * F1[164];F1[159] += F1[11] * F1[165];F1[159] += F1[13] * F1[166];F1[159] += F1[15] * F1[167];F1[159] += F1[17] * F1[168];F1[159] += F1[19] * F1[169];F1[159] += F1[21] * F1[170];F1[171] = (1 / (1 + Math.exp(-F1[159])));F1[172] = F1[171] * (1 - F1[171]);F1[173] = F1[171];972 F1[174] = F1[175];F1[175] = F1[176];F1[175] += F1[3] * F1[177];F1[175] += F1[5] * F1[178];F1[175] += F1[7] * F1[179];F1[175] += F1[9] * F1[180];F1[175] += F1[11] * F1[181];F1[175] += F1[13] * F1[182];F1[175] += F1[15] * F1[183];F1[175] += F1[17] * F1[184];F1[175] += F1[19] * F1[185];F1[175] += F1[21] * F1[186];F1[187] = (1 / (1 + Math.exp(-F1[175])));F1[188] = F1[187] * (1 - F1[187]);F1[189] = F1[187];973 F1[190] = F1[191];F1[191] = F1[125] * F1[192] * F1[191] + F1[193];F1[191] += F1[3] * F1[194] * F1[25];F1[191] += F1[5] * F1[195] * F1[26];F1[191] += F1[7] * F1[196] * F1[27];F1[191] += F1[9] * F1[197] * F1[28];F1[191] += F1[11] * F1[198] * F1[29];F1[13] = (1 / (1 + Math.exp(-F1[191])));F1[199] = F1[13] * (1 - F1[13]);974 F1[200] = F1[201];F1[201] = F1[141] * F1[202] * F1[201] + F1[203];F1[201] += F1[3] * F1[204] * F1[45];F1[201] += F1[5] * F1[205] * F1[46];F1[201] += F1[7] * F1[206] * F1[47];F1[201] += F1[9] * F1[207] * F1[48];F1[201] += F1[11] * F1[208] * F1[49];F1[15] = (1 / (1 + Math.exp(-F1[201])));F1[209] = F1[15] * (1 - F1[15]);975 F1[210] = F1[211];F1[211] = F1[157] * F1[212] * F1[211] + F1[213];F1[211] += F1[3] * F1[214] * F1[65];F1[211] += F1[5] * F1[215] * F1[66];F1[211] += F1[7] * F1[216] * F1[67];F1[211] += F1[9] * F1[217] * F1[68];F1[211] += F1[11] * F1[218] * F1[69];F1[17] = (1 / (1 + Math.exp(-F1[211])));F1[219] = F1[17] * (1 - F1[17]);976 F1[220] = F1[221];F1[221] = F1[173] * F1[222] * F1[221] + F1[223];F1[221] += F1[3] * F1[224] * F1[85];F1[221] += F1[5] * F1[225] * F1[86];F1[221] += F1[7] * F1[226] * F1[87];F1[221] += F1[9] * F1[227] * F1[88];F1[221] += F1[11] * F1[228] * F1[89];F1[19] = (1 / (1 + Math.exp(-F1[221])));F1[229] = F1[19] * (1 - F1[19]);977 F1[230] = F1[231];F1[231] = F1[189] * F1[232] * F1[231] + F1[233];F1[231] += F1[3] * F1[234] * F1[105];F1[231] += F1[5] * F1[235] * F1[106];F1[231] += F1[7] * F1[236] * F1[107];F1[231] += F1[9] * F1[237] * F1[108];F1[231] += F1[11] * F1[238] * F1[109];F1[21] = (1 / (1 + Math.exp(-F1[231])));F1[239] = F1[21] * (1 - F1[21]);978 F1[240] = F1[241];F1[241] = F1[242];F1[241] += F1[3] * F1[243];F1[241] += F1[5] * F1[244];F1[241] += F1[7] * F1[245];F1[241] += F1[9] * F1[246];F1[241] += F1[11] * F1[247];F1[241] += F1[13] * F1[248];F1[241] += F1[15] * F1[249];F1[241] += F1[17] * F1[250];F1[241] += F1[19] * F1[251];F1[241] += F1[21] * F1[252];F1[253] = (1 / (1 + Math.exp(-F1[241])));F1[254] = F1[253] * (1 - F1[253]);F1[255] = F1[253];979 F1[256] = F1[257];F1[257] = F1[258];F1[257] += F1[3] * F1[259];F1[257] += F1[5] * F1[260];F1[257] += F1[7] * F1[261];F1[257] += F1[9] * F1[262];F1[257] += F1[11] * F1[263];F1[257] += F1[13] * F1[264];F1[257] += F1[15] * F1[265];F1[257] += F1[17] * F1[266];F1[257] += F1[19] * F1[267];F1[257] += F1[21] * F1[268];F1[269] = (1 / (1 + Math.exp(-F1[257])));F1[270] = F1[269] * (1 - F1[269]);F1[271] = F1[269];980 F1[272] = F1[273];F1[273] = F1[274];F1[273] += F1[3] * F1[275];F1[273] += F1[5] * F1[276];F1[273] += F1[7] * F1[277];F1[273] += F1[9] * F1[278];F1[273] += F1[11] * F1[279];F1[273] += F1[13] * F1[280];F1[273] += F1[15] * F1[281];F1[273] += F1[17] * F1[282];F1[273] += F1[19] * F1[283];F1[273] += F1[21] * F1[284];F1[285] = (1 / (1 + Math.exp(-F1[273])));F1[286] = F1[285] * (1 - F1[285]);F1[287] = F1[285];981 F1[288] = F1[289];F1[289] = F1[290];F1[289] += F1[3] * F1[291];F1[289] += F1[5] * F1[292];F1[289] += F1[7] * F1[293];F1[289] += F1[9] * F1[294];F1[289] += F1[11] * F1[295];F1[289] += F1[13] * F1[296];F1[289] += F1[15] * F1[297];F1[289] += F1[17] * F1[298];F1[289] += F1[19] * F1[299];F1[289] += F1[21] * F1[300];F1[301] = (1 / (1 + Math.exp(-F1[289])));F1[302] = F1[301] * (1 - F1[301]);F1[303] = F1[301];982 F1[304] = F1[305];F1[305] = F1[306];F1[305] += F1[3] * F1[307];F1[305] += F1[5] * F1[308];F1[305] += F1[7] * F1[309];F1[305] += F1[9] * F1[310];F1[305] += F1[11] * F1[311];F1[305] += F1[13] * F1[312];F1[305] += F1[15] * F1[313];F1[305] += F1[17] * F1[314];F1[305] += F1[19] * F1[315];F1[305] += F1[21] * F1[316];F1[317] = (1 / (1 + Math.exp(-F1[305])));F1[318] = F1[317] * (1 - F1[317]);F1[319] = F1[317];983 F1[320] = F1[321];F1[321] = F1[322];F1[321] += F1[3] * F1[323];F1[321] += F1[5] * F1[324];F1[321] += F1[7] * F1[325];F1[321] += F1[9] * F1[326];F1[321] += F1[11] * F1[327];F1[321] += F1[13] * F1[328];F1[321] += F1[15] * F1[329];F1[321] += F1[17] * F1[330];F1[321] += F1[19] * F1[331];F1[321] += F1[21] * F1[332];F1[321] += F1[333] * F1[334];F1[321] += F1[335] * F1[336];F1[337] = (1 / (1 + Math.exp(-F1[321])));F1[338] = F1[337] * (1 - F1[337]);F1[339] = F1[337];F1[340] = F1[337];F1[341] = F1[337];F1[342] = F1[337];F1[343] = F1[337];F1[344] = F1[337];F1[345] = F1[337];F1[346] = F1[337];F1[347] = F1[337];F1[348] = F1[337];984 F1[349] = F1[350];F1[350] = F1[351];F1[350] += F1[3] * F1[352];F1[350] += F1[5] * F1[353];F1[350] += F1[7] * F1[354];F1[350] += F1[9] * F1[355];F1[350] += F1[11] * F1[356];F1[350] += F1[13] * F1[357];F1[350] += F1[15] * F1[358];F1[350] += F1[17] * F1[359];F1[350] += F1[19] * F1[360];F1[350] += F1[21] * F1[361];F1[350] += F1[333] * F1[362];F1[350] += F1[335] * F1[363];F1[364] = (1 / (1 + Math.exp(-F1[350])));F1[365] = F1[364] * (1 - F1[364]);F1[366] = F1[364];F1[367] = F1[364];F1[368] = F1[364];F1[369] = F1[364];F1[370] = F1[364];F1[371] = F1[364];F1[372] = F1[364];F1[373] = F1[364];F1[374] = F1[364];F1[375] = F1[364];985 F1[376] = F1[377];F1[377] = F1[378];F1[377] += F1[3] * F1[379];F1[377] += F1[5] * F1[380];F1[377] += F1[7] * F1[381];F1[377] += F1[9] * F1[382];F1[377] += F1[11] * F1[383];F1[377] += F1[13] * F1[384];F1[377] += F1[15] * F1[385];F1[377] += F1[17] * F1[386];F1[377] += F1[19] * F1[387];F1[377] += F1[21] * F1[388];F1[377] += F1[333] * F1[389];F1[377] += F1[335] * F1[390];F1[391] = (1 / (1 + Math.exp(-F1[377])));F1[392] = F1[391] * (1 - F1[391]);F1[393] = F1[391];986 F1[394] = F1[395];F1[395] = F1[396];F1[395] += F1[3] * F1[397];F1[395] += F1[5] * F1[398];F1[395] += F1[7] * F1[399];F1[395] += F1[9] * F1[400];F1[395] += F1[11] * F1[401];F1[395] += F1[13] * F1[402];F1[395] += F1[15] * F1[403];F1[395] += F1[17] * F1[404];F1[395] += F1[19] * F1[405];F1[395] += F1[21] * F1[406];F1[395] += F1[333] * F1[407];F1[395] += F1[335] * F1[408];F1[409] = (1 / (1 + Math.exp(-F1[395])));F1[410] = F1[409] * (1 - F1[409]);F1[411] = F1[409];987 F1[412] = F1[413];F1[413] = F1[393] * F1[414] * F1[413] + F1[415];F1[413] += F1[3] * F1[416] * F1[339];F1[413] += F1[5] * F1[417] * F1[340];F1[413] += F1[7] * F1[418] * F1[341];F1[413] += F1[9] * F1[419] * F1[342];F1[413] += F1[11] * F1[420] * F1[343];F1[413] += F1[13] * F1[421] * F1[344];F1[413] += F1[15] * F1[422] * F1[345];F1[413] += F1[17] * F1[423] * F1[346];F1[413] += F1[19] * F1[424] * F1[347];F1[413] += F1[21] * F1[425] * F1[348];F1[333] = (1 / (1 + Math.exp(-F1[413])));F1[426] = F1[333] * (1 - F1[333]);988 F1[427] = F1[428];F1[428] = F1[411] * F1[429] * F1[428] + F1[430];F1[428] += F1[3] * F1[431] * F1[366];F1[428] += F1[5] * F1[432] * F1[367];F1[428] += F1[7] * F1[433] * F1[368];F1[428] += F1[9] * F1[434] * F1[369];F1[428] += F1[11] * F1[435] * F1[370];F1[428] += F1[13] * F1[436] * F1[371];F1[428] += F1[15] * F1[437] * F1[372];F1[428] += F1[17] * F1[438] * F1[373];F1[428] += F1[19] * F1[439] * F1[374];F1[428] += F1[21] * F1[440] * F1[375];F1[335] = (1 / (1 + Math.exp(-F1[428])));F1[441] = F1[335] * (1 - F1[335]);989 F1[442] = F1[443];F1[443] = F1[444];F1[443] += F1[3] * F1[445];F1[443] += F1[5] * F1[446];F1[443] += F1[7] * F1[447];F1[443] += F1[9] * F1[448];F1[443] += F1[11] * F1[449];F1[443] += F1[13] * F1[450];F1[443] += F1[15] * F1[451];F1[443] += F1[17] * F1[452];F1[443] += F1[19] * F1[453];F1[443] += F1[21] * F1[454];F1[443] += F1[333] * F1[455];F1[443] += F1[335] * F1[456];F1[457] = (1 / (1 + Math.exp(-F1[443])));F1[458] = F1[457] * (1 - F1[457]);F1[459] = F1[457];990 F1[460] = F1[461];F1[461] = F1[462];F1[461] += F1[3] * F1[463];F1[461] += F1[5] * F1[464];F1[461] += F1[7] * F1[465];F1[461] += F1[9] * F1[466];F1[461] += F1[11] * F1[467];F1[461] += F1[13] * F1[468];F1[461] += F1[15] * F1[469];F1[461] += F1[17] * F1[470];F1[461] += F1[19] * F1[471];F1[461] += F1[21] * F1[472];F1[461] += F1[333] * F1[473];F1[461] += F1[335] * F1[474];F1[475] = (1 / (1 + Math.exp(-F1[461])));F1[476] = F1[475] * (1 - F1[475]);F1[477] = F1[475];991 F1[478] = F1[479];F1[479] = F1[480];F1[479] += F1[13] * F1[481] * F1[255];F1[479] += F1[15] * F1[482] * F1[271];F1[479] += F1[17] * F1[483] * F1[287];F1[479] += F1[19] * F1[484] * F1[303];F1[479] += F1[21] * F1[485] * F1[319];F1[479] += F1[333] * F1[486] * F1[459];F1[479] += F1[335] * F1[487] * F1[477];F1[479] += F1[3] * F1[488];F1[479] += F1[5] * F1[489];F1[479] += F1[7] * F1[490];F1[479] += F1[9] * F1[491];F1[479] += F1[11] * F1[492];F1[493] = (1 / (1 + Math.exp(-F1[479])));F1[494] = F1[493] * (1 - F1[493]);992 // var output = [];993 output[0] = F1[493];994 return output;995 }996 function runStoredModel7(feedArray){997 var output = [];998 var F2 = loadNNData7;999 F2[3] = feedArray[0];1000 F2[5] = feedArray[1];1001 F2[7] = feedArray[2];1002 F2[9] = feedArray[3];1003 F2[11] = feedArray[4];1004 F2[13] = feedArray[5];1005 F2[15] = feedArray[6];1006 F2[0] = F2[1];F2[1] = F2[2];F2[1] += F2[3] * F2[4];F2[1] += F2[5] * F2[6];F2[1] += F2[7] * F2[8];F2[1] += F2[9] * F2[10];F2[1] += F2[11] * F2[12];F2[1] += F2[13] * F2[14];F2[1] += F2[15] * F2[16];F2[1] += F2[17] * F2[18];F2[1] += F2[19] * F2[20];F2[1] += F2[21] * F2[22];F2[1] += F2[23] * F2[24];F2[1] += F2[25] * F2[26];F2[27] = (1 / (1 + Math.exp(-F2[1])));F2[28] = F2[27] * (1 - F2[27]);F2[29] = F2[27];F2[30] = F2[27];F2[31] = F2[27];F2[32] = F2[27];F2[33] = F2[27];F2[34] = F2[27];F2[35] = F2[27];1007 F2[36] = F2[37];F2[37] = F2[38];F2[37] += F2[3] * F2[39];F2[37] += F2[5] * F2[40];F2[37] += F2[7] * F2[41];F2[37] += F2[9] * F2[42];F2[37] += F2[11] * F2[43];F2[37] += F2[13] * F2[44];F2[37] += F2[15] * F2[45];F2[37] += F2[17] * F2[46];F2[37] += F2[19] * F2[47];F2[37] += F2[21] * F2[48];F2[37] += F2[23] * F2[49];F2[37] += F2[25] * F2[50];F2[51] = (1 / (1 + Math.exp(-F2[37])));F2[52] = F2[51] * (1 - F2[51]);F2[53] = F2[51];F2[54] = F2[51];F2[55] = F2[51];F2[56] = F2[51];F2[57] = F2[51];F2[58] = F2[51];F2[59] = F2[51];1008 F2[60] = F2[61];F2[61] = F2[62];F2[61] += F2[3] * F2[63];F2[61] += F2[5] * F2[64];F2[61] += F2[7] * F2[65];F2[61] += F2[9] * F2[66];F2[61] += F2[11] * F2[67];F2[61] += F2[13] * F2[68];F2[61] += F2[15] * F2[69];F2[61] += F2[17] * F2[70];F2[61] += F2[19] * F2[71];F2[61] += F2[21] * F2[72];F2[61] += F2[23] * F2[73];F2[61] += F2[25] * F2[74];F2[75] = (1 / (1 + Math.exp(-F2[61])));F2[76] = F2[75] * (1 - F2[75]);F2[77] = F2[75];F2[78] = F2[75];F2[79] = F2[75];F2[80] = F2[75];F2[81] = F2[75];F2[82] = F2[75];F2[83] = F2[75];1009 F2[84] = F2[85];F2[85] = F2[86];F2[85] += F2[3] * F2[87];F2[85] += F2[5] * F2[88];F2[85] += F2[7] * F2[89];F2[85] += F2[9] * F2[90];F2[85] += F2[11] * F2[91];F2[85] += F2[13] * F2[92];F2[85] += F2[15] * F2[93];F2[85] += F2[17] * F2[94];F2[85] += F2[19] * F2[95];F2[85] += F2[21] * F2[96];F2[85] += F2[23] * F2[97];F2[85] += F2[25] * F2[98];F2[99] = (1 / (1 + Math.exp(-F2[85])));F2[100] = F2[99] * (1 - F2[99]);F2[101] = F2[99];F2[102] = F2[99];F2[103] = F2[99];F2[104] = F2[99];F2[105] = F2[99];F2[106] = F2[99];F2[107] = F2[99];1010 F2[108] = F2[109];F2[109] = F2[110];F2[109] += F2[3] * F2[111];F2[109] += F2[5] * F2[112];F2[109] += F2[7] * F2[113];F2[109] += F2[9] * F2[114];F2[109] += F2[11] * F2[115];F2[109] += F2[13] * F2[116];F2[109] += F2[15] * F2[117];F2[109] += F2[17] * F2[118];F2[109] += F2[19] * F2[119];F2[109] += F2[21] * F2[120];F2[109] += F2[23] * F2[121];F2[109] += F2[25] * F2[122];F2[123] = (1 / (1 + Math.exp(-F2[109])));F2[124] = F2[123] * (1 - F2[123]);F2[125] = F2[123];F2[126] = F2[123];F2[127] = F2[123];F2[128] = F2[123];F2[129] = F2[123];F2[130] = F2[123];F2[131] = F2[123];1011 F2[132] = F2[133];F2[133] = F2[134];F2[133] += F2[3] * F2[135];F2[133] += F2[5] * F2[136];F2[133] += F2[7] * F2[137];F2[133] += F2[9] * F2[138];F2[133] += F2[11] * F2[139];F2[133] += F2[13] * F2[140];F2[133] += F2[15] * F2[141];F2[133] += F2[17] * F2[142];F2[133] += F2[19] * F2[143];F2[133] += F2[21] * F2[144];F2[133] += F2[23] * F2[145];F2[133] += F2[25] * F2[146];F2[147] = (1 / (1 + Math.exp(-F2[133])));F2[148] = F2[147] * (1 - F2[147]);F2[149] = F2[147];1012 F2[150] = F2[151];F2[151] = F2[152];F2[151] += F2[3] * F2[153];F2[151] += F2[5] * F2[154];F2[151] += F2[7] * F2[155];F2[151] += F2[9] * F2[156];F2[151] += F2[11] * F2[157];F2[151] += F2[13] * F2[158];F2[151] += F2[15] * F2[159];F2[151] += F2[17] * F2[160];F2[151] += F2[19] * F2[161];F2[151] += F2[21] * F2[162];F2[151] += F2[23] * F2[163];F2[151] += F2[25] * F2[164];F2[165] = (1 / (1 + Math.exp(-F2[151])));F2[166] = F2[165] * (1 - F2[165]);F2[167] = F2[165];1013 F2[168] = F2[169];F2[169] = F2[170];F2[169] += F2[3] * F2[171];F2[169] += F2[5] * F2[172];F2[169] += F2[7] * F2[173];F2[169] += F2[9] * F2[174];F2[169] += F2[11] * F2[175];F2[169] += F2[13] * F2[176];F2[169] += F2[15] * F2[177];F2[169] += F2[17] * F2[178];F2[169] += F2[19] * F2[179];F2[169] += F2[21] * F2[180];F2[169] += F2[23] * F2[181];F2[169] += F2[25] * F2[182];F2[183] = (1 / (1 + Math.exp(-F2[169])));F2[184] = F2[183] * (1 - F2[183]);F2[185] = F2[183];1014 F2[186] = F2[187];F2[187] = F2[188];F2[187] += F2[3] * F2[189];F2[187] += F2[5] * F2[190];F2[187] += F2[7] * F2[191];F2[187] += F2[9] * F2[192];F2[187] += F2[11] * F2[193];F2[187] += F2[13] * F2[194];F2[187] += F2[15] * F2[195];F2[187] += F2[17] * F2[196];F2[187] += F2[19] * F2[197];F2[187] += F2[21] * F2[198];F2[187] += F2[23] * F2[199];F2[187] += F2[25] * F2[200];F2[201] = (1 / (1 + Math.exp(-F2[187])));F2[202] = F2[201] * (1 - F2[201]);F2[203] = F2[201];1015 F2[204] = F2[205];F2[205] = F2[206];F2[205] += F2[3] * F2[207];F2[205] += F2[5] * F2[208];F2[205] += F2[7] * F2[209];F2[205] += F2[9] * F2[210];F2[205] += F2[11] * F2[211];F2[205] += F2[13] * F2[212];F2[205] += F2[15] * F2[213];F2[205] += F2[17] * F2[214];F2[205] += F2[19] * F2[215];F2[205] += F2[21] * F2[216];F2[205] += F2[23] * F2[217];F2[205] += F2[25] * F2[218];F2[219] = (1 / (1 + Math.exp(-F2[205])));F2[220] = F2[219] * (1 - F2[219]);F2[221] = F2[219];1016 F2[222] = F2[223];F2[223] = F2[149] * F2[224] * F2[223] + F2[225];F2[223] += F2[3] * F2[226] * F2[29];F2[223] += F2[5] * F2[227] * F2[30];F2[223] += F2[7] * F2[228] * F2[31];F2[223] += F2[9] * F2[229] * F2[32];F2[223] += F2[11] * F2[230] * F2[33];F2[223] += F2[13] * F2[231] * F2[34];F2[223] += F2[15] * F2[232] * F2[35];F2[17] = (1 / (1 + Math.exp(-F2[223])));F2[233] = F2[17] * (1 - F2[17]);1017 F2[234] = F2[235];F2[235] = F2[167] * F2[236] * F2[235] + F2[237];F2[235] += F2[3] * F2[238] * F2[53];F2[235] += F2[5] * F2[239] * F2[54];F2[235] += F2[7] * F2[240] * F2[55];F2[235] += F2[9] * F2[241] * F2[56];F2[235] += F2[11] * F2[242] * F2[57];F2[235] += F2[13] * F2[243] * F2[58];F2[235] += F2[15] * F2[244] * F2[59];F2[19] = (1 / (1 + Math.exp(-F2[235])));F2[245] = F2[19] * (1 - F2[19]);1018 F2[246] = F2[247];F2[247] = F2[185] * F2[248] * F2[247] + F2[249];F2[247] += F2[3] * F2[250] * F2[77];F2[247] += F2[5] * F2[251] * F2[78];F2[247] += F2[7] * F2[252] * F2[79];F2[247] += F2[9] * F2[253] * F2[80];F2[247] += F2[11] * F2[254] * F2[81];F2[247] += F2[13] * F2[255] * F2[82];F2[247] += F2[15] * F2[256] * F2[83];F2[21] = (1 / (1 + Math.exp(-F2[247])));F2[257] = F2[21] * (1 - F2[21]);1019 F2[258] = F2[259];F2[259] = F2[203] * F2[260] * F2[259] + F2[261];F2[259] += F2[3] * F2[262] * F2[101];F2[259] += F2[5] * F2[263] * F2[102];F2[259] += F2[7] * F2[264] * F2[103];F2[259] += F2[9] * F2[265] * F2[104];F2[259] += F2[11] * F2[266] * F2[105];F2[259] += F2[13] * F2[267] * F2[106];F2[259] += F2[15] * F2[268] * F2[107];F2[23] = (1 / (1 + Math.exp(-F2[259])));F2[269] = F2[23] * (1 - F2[23]);1020 F2[270] = F2[271];F2[271] = F2[221] * F2[272] * F2[271] + F2[273];F2[271] += F2[3] * F2[274] * F2[125];F2[271] += F2[5] * F2[275] * F2[126];F2[271] += F2[7] * F2[276] * F2[127];F2[271] += F2[9] * F2[277] * F2[128];F2[271] += F2[11] * F2[278] * F2[129];F2[271] += F2[13] * F2[279] * F2[130];F2[271] += F2[15] * F2[280] * F2[131];F2[25] = (1 / (1 + Math.exp(-F2[271])));F2[281] = F2[25] * (1 - F2[25]);1021 F2[282] = F2[283];F2[283] = F2[284];F2[283] += F2[3] * F2[285];F2[283] += F2[5] * F2[286];F2[283] += F2[7] * F2[287];F2[283] += F2[9] * F2[288];F2[283] += F2[11] * F2[289];F2[283] += F2[13] * F2[290];F2[283] += F2[15] * F2[291];F2[283] += F2[17] * F2[292];F2[283] += F2[19] * F2[293];F2[283] += F2[21] * F2[294];F2[283] += F2[23] * F2[295];F2[283] += F2[25] * F2[296];F2[297] = (1 / (1 + Math.exp(-F2[283])));F2[298] = F2[297] * (1 - F2[297]);F2[299] = F2[297];1022 F2[300] = F2[301];F2[301] = F2[302];F2[301] += F2[3] * F2[303];F2[301] += F2[5] * F2[304];F2[301] += F2[7] * F2[305];F2[301] += F2[9] * F2[306];F2[301] += F2[11] * F2[307];F2[301] += F2[13] * F2[308];F2[301] += F2[15] * F2[309];F2[301] += F2[17] * F2[310];F2[301] += F2[19] * F2[311];F2[301] += F2[21] * F2[312];F2[301] += F2[23] * F2[313];F2[301] += F2[25] * F2[314];F2[315] = (1 / (1 + Math.exp(-F2[301])));F2[316] = F2[315] * (1 - F2[315]);F2[317] = F2[315];1023 F2[318] = F2[319];F2[319] = F2[320];F2[319] += F2[3] * F2[321];F2[319] += F2[5] * F2[322];F2[319] += F2[7] * F2[323];F2[319] += F2[9] * F2[324];F2[319] += F2[11] * F2[325];F2[319] += F2[13] * F2[326];F2[319] += F2[15] * F2[327];F2[319] += F2[17] * F2[328];F2[319] += F2[19] * F2[329];F2[319] += F2[21] * F2[330];F2[319] += F2[23] * F2[331];F2[319] += F2[25] * F2[332];F2[333] = (1 / (1 + Math.exp(-F2[319])));F2[334] = F2[333] * (1 - F2[333]);F2[335] = F2[333];1024 F2[336] = F2[337];F2[337] = F2[338];F2[337] += F2[3] * F2[339];F2[337] += F2[5] * F2[340];F2[337] += F2[7] * F2[341];F2[337] += F2[9] * F2[342];F2[337] += F2[11] * F2[343];F2[337] += F2[13] * F2[344];F2[337] += F2[15] * F2[345];F2[337] += F2[17] * F2[346];F2[337] += F2[19] * F2[347];F2[337] += F2[21] * F2[348];F2[337] += F2[23] * F2[349];F2[337] += F2[25] * F2[350];F2[351] = (1 / (1 + Math.exp(-F2[337])));F2[352] = F2[351] * (1 - F2[351]);F2[353] = F2[351];1025 F2[354] = F2[355];F2[355] = F2[356];F2[355] += F2[3] * F2[357];F2[355] += F2[5] * F2[358];F2[355] += F2[7] * F2[359];F2[355] += F2[9] * F2[360];F2[355] += F2[11] * F2[361];F2[355] += F2[13] * F2[362];F2[355] += F2[15] * F2[363];F2[355] += F2[17] * F2[364];F2[355] += F2[19] * F2[365];F2[355] += F2[21] * F2[366];F2[355] += F2[23] * F2[367];F2[355] += F2[25] * F2[368];F2[369] = (1 / (1 + Math.exp(-F2[355])));F2[370] = F2[369] * (1 - F2[369]);F2[371] = F2[369];1026 F2[372] = F2[373];F2[373] = F2[374];F2[373] += F2[3] * F2[375];F2[373] += F2[5] * F2[376];F2[373] += F2[7] * F2[377];F2[373] += F2[9] * F2[378];F2[373] += F2[11] * F2[379];F2[373] += F2[13] * F2[380];F2[373] += F2[15] * F2[381];F2[373] += F2[17] * F2[382];F2[373] += F2[19] * F2[383];F2[373] += F2[21] * F2[384];F2[373] += F2[23] * F2[385];F2[373] += F2[25] * F2[386];F2[373] += F2[387] * F2[388];F2[373] += F2[389] * F2[390];F2[391] = (1 / (1 + Math.exp(-F2[373])));F2[392] = F2[391] * (1 - F2[391]);F2[393] = F2[391];F2[394] = F2[391];F2[395] = F2[391];F2[396] = F2[391];F2[397] = F2[391];F2[398] = F2[391];F2[399] = F2[391];F2[400] = F2[391];F2[401] = F2[391];F2[402] = F2[391];F2[403] = F2[391];F2[404] = F2[391];1027 F2[405] = F2[406];F2[406] = F2[407];F2[406] += F2[3] * F2[408];F2[406] += F2[5] * F2[409];F2[406] += F2[7] * F2[410];F2[406] += F2[9] * F2[411];F2[406] += F2[11] * F2[412];F2[406] += F2[13] * F2[413];F2[406] += F2[15] * F2[414];F2[406] += F2[17] * F2[415];F2[406] += F2[19] * F2[416];F2[406] += F2[21] * F2[417];F2[406] += F2[23] * F2[418];F2[406] += F2[25] * F2[419];F2[406] += F2[387] * F2[420];F2[406] += F2[389] * F2[421];F2[422] = (1 / (1 + Math.exp(-F2[406])));F2[423] = F2[422] * (1 - F2[422]);F2[424] = F2[422];F2[425] = F2[422];F2[426] = F2[422];F2[427] = F2[422];F2[428] = F2[422];F2[429] = F2[422];F2[430] = F2[422];F2[431] = F2[422];F2[432] = F2[422];F2[433] = F2[422];F2[434] = F2[422];F2[435] = F2[422];1028 F2[436] = F2[437];F2[437] = F2[438];F2[437] += F2[3] * F2[439];F2[437] += F2[5] * F2[440];F2[437] += F2[7] * F2[441];F2[437] += F2[9] * F2[442];F2[437] += F2[11] * F2[443];F2[437] += F2[13] * F2[444];F2[437] += F2[15] * F2[445];F2[437] += F2[17] * F2[446];F2[437] += F2[19] * F2[447];F2[437] += F2[21] * F2[448];F2[437] += F2[23] * F2[449];F2[437] += F2[25] * F2[450];F2[437] += F2[387] * F2[451];F2[437] += F2[389] * F2[452];F2[453] = (1 / (1 + Math.exp(-F2[437])));F2[454] = F2[453] * (1 - F2[453]);F2[455] = F2[453];1029 F2[456] = F2[457];F2[457] = F2[458];F2[457] += F2[3] * F2[459];F2[457] += F2[5] * F2[460];F2[457] += F2[7] * F2[461];F2[457] += F2[9] * F2[462];F2[457] += F2[11] * F2[463];F2[457] += F2[13] * F2[464];F2[457] += F2[15] * F2[465];F2[457] += F2[17] * F2[466];F2[457] += F2[19] * F2[467];F2[457] += F2[21] * F2[468];F2[457] += F2[23] * F2[469];F2[457] += F2[25] * F2[470];F2[457] += F2[387] * F2[471];F2[457] += F2[389] * F2[472];F2[473] = (1 / (1 + Math.exp(-F2[457])));F2[474] = F2[473] * (1 - F2[473]);F2[475] = F2[473];1030 F2[476] = F2[477];F2[477] = F2[455] * F2[478] * F2[477] + F2[479];F2[477] += F2[3] * F2[480] * F2[393];F2[477] += F2[5] * F2[481] * F2[394];F2[477] += F2[7] * F2[482] * F2[395];F2[477] += F2[9] * F2[483] * F2[396];F2[477] += F2[11] * F2[484] * F2[397];F2[477] += F2[13] * F2[485] * F2[398];F2[477] += F2[15] * F2[486] * F2[399];F2[477] += F2[17] * F2[487] * F2[400];F2[477] += F2[19] * F2[488] * F2[401];F2[477] += F2[21] * F2[489] * F2[402];F2[477] += F2[23] * F2[490] * F2[403];F2[477] += F2[25] * F2[491] * F2[404];F2[387] = (1 / (1 + Math.exp(-F2[477])));F2[492] = F2[387] * (1 - F2[387]);1031 F2[493] = F2[494];F2[494] = F2[475] * F2[495] * F2[494] + F2[496];F2[494] += F2[3] * F2[497] * F2[424];F2[494] += F2[5] * F2[498] * F2[425];F2[494] += F2[7] * F2[499] * F2[426];F2[494] += F2[9] * F2[500] * F2[427];F2[494] += F2[11] * F2[501] * F2[428];F2[494] += F2[13] * F2[502] * F2[429];F2[494] += F2[15] * F2[503] * F2[430];F2[494] += F2[17] * F2[504] * F2[431];F2[494] += F2[19] * F2[505] * F2[432];F2[494] += F2[21] * F2[506] * F2[433];F2[494] += F2[23] * F2[507] * F2[434];F2[494] += F2[25] * F2[508] * F2[435];F2[389] = (1 / (1 + Math.exp(-F2[494])));F2[509] = F2[389] * (1 - F2[389]);1032 F2[510] = F2[511];F2[511] = F2[512];F2[511] += F2[3] * F2[513];F2[511] += F2[5] * F2[514];F2[511] += F2[7] * F2[515];F2[511] += F2[9] * F2[516];F2[511] += F2[11] * F2[517];F2[511] += F2[13] * F2[518];F2[511] += F2[15] * F2[519];F2[511] += F2[17] * F2[520];F2[511] += F2[19] * F2[521];F2[511] += F2[21] * F2[522];F2[511] += F2[23] * F2[523];F2[511] += F2[25] * F2[524];F2[511] += F2[387] * F2[525];F2[511] += F2[389] * F2[526];F2[527] = (1 / (1 + Math.exp(-F2[511])));F2[528] = F2[527] * (1 - F2[527]);F2[529] = F2[527];1033 F2[530] = F2[531];F2[531] = F2[532];F2[531] += F2[3] * F2[533];F2[531] += F2[5] * F2[534];F2[531] += F2[7] * F2[535];F2[531] += F2[9] * F2[536];F2[531] += F2[11] * F2[537];F2[531] += F2[13] * F2[538];F2[531] += F2[15] * F2[539];F2[531] += F2[17] * F2[540];F2[531] += F2[19] * F2[541];F2[531] += F2[21] * F2[542];F2[531] += F2[23] * F2[543];F2[531] += F2[25] * F2[544];F2[531] += F2[387] * F2[545];F2[531] += F2[389] * F2[546];F2[547] = (1 / (1 + Math.exp(-F2[531])));F2[548] = F2[547] * (1 - F2[547]);F2[549] = F2[547];1034 F2[550] = F2[551];F2[551] = F2[552];F2[551] += F2[17] * F2[553] * F2[299];F2[551] += F2[19] * F2[554] * F2[317];F2[551] += F2[21] * F2[555] * F2[335];F2[551] += F2[23] * F2[556] * F2[353];F2[551] += F2[25] * F2[557] * F2[371];F2[551] += F2[387] * F2[558] * F2[529];F2[551] += F2[389] * F2[559] * F2[549];F2[551] += F2[3] * F2[560];F2[551] += F2[5] * F2[561];F2[551] += F2[7] * F2[562];F2[551] += F2[9] * F2[563];F2[551] += F2[11] * F2[564];F2[551] += F2[13] * F2[565];F2[551] += F2[15] * F2[566];F2[567] = (1 / (1 + Math.exp(-F2[551])));F2[568] = F2[567] * (1 - F2[567]);1035 // var output = [];1036 output[0] = F2[567];1037 return output;1038 }1039 /********************************************************************************************************************1040 *********************************************** CHANGE CURRENT TARGET ***********************************************1041 ********************************************************************************************************************/1042 $('.target-select-radio').click(function() {1043 selectedTargetNum = parseInt( $(this).attr("num") );1044 selectedTargetName = $(this).attr("id");1045 var isChecked = $('#rdSelect').prop('checked');1046 console.log("SELECTED TARGET: " + selectedTargetName + " " + selectedTargetNum + " " + isChecked);1047 });1048 /********************************************************************************************************************1049 *********************************************** SLIDER UI ***********************************************************1050 ********************************************************************************************************************/1051 var rangeSlider = function(){1052 var slider = $('.range-slider'),1053 range = $('.range-slider__range'),1054 value = $('.range-slider__value');1055 1056 slider.each(function(){1057 value.each(function(){1058 var value = $(this).prev().attr('value');1059 $(this).html(value);1060 });1061 if( $(this).hasClass('nn-architecture') ){ $('.range-slider__value.nn-architecture').html('2:5:1'); }1062 range.on('input', function(){1063 var labels = ['2:1', '2:5:1', '2:5:5:1', '3:1', '3:5:1', '3:5:5:1', '5:1', '5:5:1', '5:7:7:1'];1064 $(this).next(value).html(this.value);1065 if( $(this).hasClass('nn-architecture') ){ $(this).next(value).html( labels[this.value] ); }1066 1067 });1068 });1069 }1070 rangeSlider();1071 //RANGE SLIDER EVENT HANDLER1072 $( ".range-slider" ).each(function() {1073 if($(this).hasClass("nn-architecture")){1074 // Add labels to slider whose values 1075 // are specified by min, max and whose1076 // step is set to 11077 1078 // Get the options for this slider1079 //var opt = $(this).data().uiSlider.options;1080 // Get the number of possible values1081 var $input = $(this).find("input");1082 var min = parseInt($input.attr("min"));1083 var max = parseInt($input.attr("max"));1084 var step = parseInt($input.attr("step"));1085 var increment = parseInt($input.attr("increment"));1086 var vals = max - min; //opt.max - opt.min;1087 //if(min < 0){ vals = max + min; }1088 var labels = ['2:1', '2:5:1', '2:5:5:1', '3:1', '3:5:1', '3:5:5:1', '5:1', '5:5:1', '5:7:7:1'];1089 1090 // Space out values1091 for (var i = 0; (i * increment) <= vals; i++) {1092 var s = min + (i * increment);1093 var el = $('<label>'+ labels[s] +'</label>').css('left',( 4 + Math.abs((s-min)/vals) *($input.width() -24)+'px'));1094 // var el = $('<label>'+ s +'</label>').css('left',( 3 + ((s-min)/vals) *($input.width() -24)+'px'));1095 if(s == 0){ el = $('<label>'+ labels[s] +'</label>').css('left',( 21 + Math.abs((s-min)/vals) *($input.width() -24)+'px')); }1096 if(s == vals){ el = $('<label>'+ labels[s] +'</label>').css('left',( -20 + Math.abs((s-min)/vals) *($input.width() -24)+'px')); }1097 $(this).append(el);1098 }1099 } 1100 });1101 /*******************************************************************************************************************1102 ******************************************* NEURAL NETWORK BUTTONS *************************************************1103 ********************************************************************************************************************/1104 $('#train-btn').click(function() {1105 console.log("train button 1");1106 trainNNFlag1 = true;1107 trainNN(1);1108 });1109 $('#activate-btn').click(function() {1110 console.log("activate button");1111 activeNNFlag1 = true;1112 $('#activate-btn').toggleClass("activatedNN");1113 //if loaded NN, turn off1114 if (loadNNFlag) {1115 loadNNFlag = false;1116 $('#load-nn-btn').toggleClass("activatedNN");1117 }1118 });1119 $('#train2-btn').click(function() {1120 console.log("train button 2");1121 trainNNFlag2 = true;1122 trainNN(2);1123 });1124 $('#activate2-btn').click(function() {1125 console.log("activate button");1126 activeNNFlag2 = true;1127 $('#activate2-btn').toggleClass("activatedNN");1128 //if leaded NN, turn off1129 if (loadNNFlag) {1130 loadNNFlag = false;1131 $('#load-nn-btn').toggleClass("activatedNN");1132 }1133 });1134 // ************* LOAD TWO EXPORTED NEURAL NET ACTIVATION FUNCTIONS AND WEIGHTS1135 $('#load-nn-btn').click(function() {1136 console.log("load exported NN button");1137 loadNNFlag = true;1138 $('#load-nn-btn').toggleClass("activatedNN");1139 console.log("LOADING MODEL FOR TARGET: " + selectedTargetName + " " + selectedTargetNum);1140 //SHORT RIGHT1141 if(selectedTargetName == 'sh-r-eyes-select'){1142 loadNNData5 = set_RHand_ShortHair_EyesPosition_5Weights(loadNNData5);1143 loadNNData7 = set_RHand_ShortHair_EyesPosition_7Weights(loadNNData7);1144 } else if(selectedTargetName == 'sh-r-mouth-select'){1145 loadNNData5 = set_RHand_ShortHair_MouthPosition_5Weights(loadNNData5);1146 loadNNData7 = set_RHand_ShortHair_MouthPosition_7Weights(loadNNData7);1147 } else if(selectedTargetName == 'sh-r-front-select'){1148 loadNNData5 = set_RHand_ShortHair_FrontPosition_5Weights(loadNNData5);1149 loadNNData7 = set_RHand_ShortHair_FrontPosition_7Weights(loadNNData7);1150 } else if(selectedTargetName == 'sh-r-side-select'){1151 loadNNData5 = set_RHand_ShortHair_SidePosition_5Weights(loadNNData5);1152 loadNNData7 = set_RHand_ShortHair_SidePosition_7Weights(loadNNData7);1153 } else if(selectedTargetName == 'sh-r-top-select'){1154 loadNNData5 = set_RHand_ShortHair_TopPosition_5Weights(loadNNData5);1155 loadNNData7 = set_RHand_ShortHair_TopPosition_7Weights(loadNNData7);1156 } else if(selectedTargetName == 'sh-r-back-select'){1157 loadNNData5 = set_RHand_ShortHair_BackPosition_5Weights(loadNNData5);1158 loadNNData7 = set_RHand_ShortHair_BackPosition_7Weights(loadNNData7);1159 }1160 //SHORT LEFT1161 else if(selectedTargetName == 'sh-l-eyes-select'){1162 loadNNData5 = set_LHand_ShortHair_EyesPosition_5Weights(loadNNData5);1163 loadNNData7 = set_LHand_ShortHair_EyesPosition_7Weights(loadNNData7);1164 } else if(selectedTargetName == 'sh-l-mouth-select'){1165 loadNNData5 = set_LHand_ShortHair_MouthPosition_5Weights(loadNNData5);1166 loadNNData7 = set_LHand_ShortHair_MouthPosition_7Weights(loadNNData7);1167 } else if(selectedTargetName == 'sh-l-front-select'){1168 loadNNData5 = set_LHand_ShortHair_FrontPosition_5Weights(loadNNData5);1169 loadNNData7 = set_LHand_ShortHair_FrontPosition_7Weights(loadNNData7);1170 } else if(selectedTargetName == 'sh-l-side-select'){1171 loadNNData5 = set_LHand_ShortHair_SidePosition_5Weights(loadNNData5);1172 loadNNData7 = set_LHand_ShortHair_SidePosition_7Weights(loadNNData7);1173 } else if(selectedTargetName == 'sh-l-top-select'){1174 loadNNData5 = set_LHand_ShortHair_TopPosition_5Weights(loadNNData5);1175 loadNNData7 = set_LHand_ShortHair_TopPosition_7Weights(loadNNData7);1176 } else if(selectedTargetName == 'sh-l-back-select'){1177 loadNNData5 = set_LHand_ShortHair_BackPosition_5Weights(loadNNData5);1178 loadNNData7 = set_LHand_ShortHair_BackPosition_7Weights(loadNNData7);1179 }1180 //MEDIUM LEFT1181 else if(selectedTargetName == 'md-l-eyes-select'){1182 loadNNData5 = set_LHand_MediumHair_EyesPosition_5Weights(loadNNData5);1183 loadNNData7 = set_LHand_MediumHair_EyesPosition_7Weights(loadNNData7);1184 } else if(selectedTargetName == 'md-l-mouth-select'){1185 loadNNData5 = set_LHand_MediumHair_MouthPosition_5Weights(loadNNData5);1186 loadNNData7 = set_LHand_MediumHair_MouthPosition_7Weights(loadNNData7);1187 } else if(selectedTargetName == 'md-l-front-select'){1188 loadNNData5 = set_LHand_MediumHair_FrontPosition_5Weights(loadNNData5);1189 loadNNData7 = set_LHand_MediumHair_FrontPosition_7Weights(loadNNData7);1190 } else if(selectedTargetName == 'md-l-side-select'){1191 loadNNData5 = set_LHand_MediumHair_SidePosition_5Weights(loadNNData5);1192 loadNNData7 = set_LHand_MediumHair_SidePosition_7Weights(loadNNData7);1193 } else if(selectedTargetName == 'md-l-top-select'){1194 loadNNData5 = set_LHand_MediumHair_TopPosition_5Weights(loadNNData5);1195 loadNNData7 = set_LHand_MediumHair_TopPosition_7Weights(loadNNData7);1196 } else if(selectedTargetName == 'md-l-back-select'){1197 loadNNData5 = set_LHand_MediumHair_BackPosition_5Weights(loadNNData5);1198 loadNNData7 = set_LHand_MediumHair_BackPosition_7Weights(loadNNData7);1199 }1200 //MEDIUM RIGHT1201 else if(selectedTargetName == 'md-r-eyes-select'){1202 loadNNData5 = set_RHand_MediumHair_EyesPosition_5Weights(loadNNData5);1203 loadNNData7 = set_RHand_MediumHair_EyesPosition_7Weights(loadNNData7);1204 } else if(selectedTargetName == 'md-r-mouth-select'){1205 loadNNData5 = set_RHand_MediumHair_MouthPosition_5Weights(loadNNData5);1206 loadNNData7 = set_RHand_MediumHair_MouthPosition_7Weights(loadNNData7);1207 } else if(selectedTargetName == 'md-r-front-select'){1208 loadNNData5 = set_RHand_MediumHair_FrontPosition_5Weights(loadNNData5);1209 loadNNData7 = set_RHand_MediumHair_FrontPosition_7Weights(loadNNData7);1210 } else if(selectedTargetName == 'md-r-side-select'){1211 loadNNData5 = set_RHand_MediumHair_SidePosition_5Weights(loadNNData5);1212 loadNNData7 = set_RHand_MediumHair_SidePosition_7Weights(loadNNData7);1213 } else if(selectedTargetName == 'md-r-top-select'){1214 loadNNData5 = set_RHand_MediumHair_TopPosition_5Weights(loadNNData5);1215 loadNNData7 = set_RHand_MediumHair_TopPosition_7Weights(loadNNData7);1216 } else if(selectedTargetName == 'md-r-back-select'){1217 loadNNData5 = set_RHand_MediumHair_BackPosition_5Weights(loadNNData5);1218 loadNNData7 = set_RHand_MediumHair_BackPosition_7Weights(loadNNData7);1219 }1220 //LONG LEFT1221 else if(selectedTargetName == 'lg-l-eyes-select'){1222 loadNNData5 = set_LHand_LongHair_EyesPosition_5Weights(loadNNData5);1223 loadNNData7 = set_LHand_LongHair_EyesPosition_7Weights(loadNNData7);1224 } else if(selectedTargetName == 'lg-l-mouth-select'){1225 loadNNData5 = set_LHand_LongHair_MouthPosition_5Weights(loadNNData5);1226 loadNNData7 = set_LHand_LongHair_MouthPosition_7Weights(loadNNData7);1227 } else if(selectedTargetName == 'lg-l-front-select'){1228 loadNNData5 = set_LHand_LongHair_FrontPosition_5Weights(loadNNData5);1229 loadNNData7 = set_LHand_LongHair_FrontPosition_7Weights(loadNNData7);1230 } else if(selectedTargetName == 'lg-l-side-select'){1231 loadNNData5 = set_LHand_LongHair_SidePosition_5Weights(loadNNData5);1232 loadNNData7 = set_LHand_LongHair_SidePosition_7Weights(loadNNData7);1233 } else if(selectedTargetName == 'lg-l-top-select'){1234 loadNNData5 = set_LHand_LongHair_TopPosition_5Weights(loadNNData5);1235 loadNNData7 = set_LHand_LongHair_TopPosition_7Weights(loadNNData7);1236 } else if(selectedTargetName == 'lg-l-back-select'){1237 loadNNData5 = set_LHand_LongHair_BackPosition_5Weights(loadNNData5);1238 loadNNData7 = set_LHand_LongHair_BackPosition_7Weights(loadNNData7);1239 }1240 //LONG RIGHT1241 else if(selectedTargetName == 'lg-r-eyes-select'){1242 loadNNData5 = set_RHand_LongHair_EyesPosition_5Weights(loadNNData5);1243 loadNNData7 = set_RHand_LongHair_EyesPosition_7Weights(loadNNData7);1244 } else if(selectedTargetName == 'lg-r-mouth-select'){1245 loadNNData5 = set_RHand_LongHair_MouthPosition_5Weights(loadNNData5);1246 loadNNData7 = set_RHand_LongHair_MouthPosition_7Weights(loadNNData7);1247 } else if(selectedTargetName == 'lg-r-front-select'){1248 loadNNData5 = set_RHand_LongHair_FrontPosition_5Weights(loadNNData5);1249 loadNNData7 = set_RHand_LongHair_FrontPosition_7Weights(loadNNData7);1250 } else if(selectedTargetName == 'lg-r-side-select'){1251 loadNNData5 = set_RHand_LongHair_SidePosition_5Weights(loadNNData5);1252 loadNNData7 = set_RHand_LongHair_SidePosition_7Weights(loadNNData7);1253 } else if(selectedTargetName == 'lg-r-top-select'){1254 loadNNData5 = set_RHand_LongHair_TopPosition_5Weights(loadNNData5);1255 loadNNData7 = set_RHand_LongHair_TopPosition_7Weights(loadNNData7);1256 } else if(selectedTargetName == 'lg-r-back-select'){1257 loadNNData5 = set_RHand_LongHair_BackPosition_5Weights(loadNNData5);1258 loadNNData7 = set_RHand_LongHair_BackPosition_7Weights(loadNNData7);1259 }1260 });1261 /*******************************************************************************************************************1262 ********************************** COLLECT, PRINT, LOAD BUTTON ACTIONS *********************************************1263 ********************************************************************************************************************/1264 /*************** COLLECT SAMPLE - SONSOR AND MODEL DATA - STORE IN GSHEET AND ADD TO NN TRAINING OBJECT *****************/1265 $('#collect-true-1').click(function() {1266 //how many samples for this set?1267 getSamplesFlag = $('input.sample-size').val();1268 getSamplesTypeFlag = 1;1269 console.log("Collect btn NN1T #samples flag: " + getSamplesFlag);1270 });1271 $('#collect-false-1').click(function() {1272 //how many samples for this set?1273 //this flag is applied in the bluetooth data notification function1274 getSamplesFlag = $('input.sample-size').val();1275 getSamplesTypeFlag = 2;1276 console.log("Collect btn NN1F #samples flag: " + getSamplesFlag);1277 });1278 $('#collect-true-2').click(function() {1279 //how many samples for this set?1280 getSamplesFlag = $('input.sample-size').val();1281 //this flag is applied in the bluetooth data notification function1282 getSamplesTypeFlag = 3;1283 console.log("Collect btn NN2T #samples flag: " + getSamplesFlag);1284 });1285 $('#collect-false-2').click(function() {1286 //how many samples for this set?1287 getSamplesFlag = $('input.sample-size').val();1288 //this flag is applied in the bluetooth data notification function1289 getSamplesTypeFlag = 4;1290 console.log("Collect btn NN2F #samples flag: " + getSamplesFlag);1291 });1292 $('#clear-1').click(function() {1293 NN1TrueDataArray = new Array;1294 NN1FalseDataArray = new Array;1295 sensorDataArray = new Array(18).fill(0);1296 sensorDataSession = new Array;1297 updateSampleCountDisplay();1298 $("#dump-print").html("");1299 console.log("Clear NN1 Data");1300 });1301 $('#clear-2').click(function() {1302 NN2TrueDataArray = new Array;1303 NN2FalseDataArray = new Array;1304 sensorDataArray = new Array(18).fill(0);1305 sensorDataSession = new Array;1306 updateSampleCountDisplay();1307 $("#dump-print").html("");1308 console.log("Clear NN2 Data");1309 });1310 $('#export-btn').click(function() {1311 console.log("export1 NN button");1312 //clear everything but key values from stored NN1313 neuralNet.clear();1314 //export optimized weights and activation function1315 var standalone = neuralNet.standalone();1316 //convert to string for parsing1317 standalone = standalone.toString();1318 console.log(standalone);1319 $("#dump-print").html(standalone);1320 $("#dump-print").addClass("active-print");1321 });1322 $('#export2-btn').click(function() {1323 console.log("export2 NN button");1324 //clear everything but key values from stored NN1325 neuralNet2.clear();1326 //export optimized weights and activation function1327 var standalone = neuralNet2.standalone();1328 //convert to string for parsing1329 standalone = standalone.toString();1330 console.log(standalone);1331 $("#dump-print").html(standalone);1332 $("#dump-print").addClass("active-print");1333 });1334 //print sensor data to browser at bottom of app screen1335 $('#print-btn').click(function() {1336 console.log("print button");1337 $("#dump-print").html("");1338 var dataVarNames=["sh_r_eyes_data", "sh_r_mouth_data", "sh_r_front_data", "sh_r_side_data", "sh_r_top_data", "sh_r_back_data", "sh_r_off_data",1339 "sh_l_eyes_data", "sh_l_mouth_data", "sh_l_front_data", "sh_l_side_data", "sh_l_top_data", "sh_l_back_data", "sh_l_off_data",1340 "md_r_eyes_data", "md_r_mouth_data", "md_r_front_data", "md_r_side_data", "md_r_top_data", "md_r_back_data", "md_r_off_data",1341 "md_l_eyes_data", "md_l_mouth_data", "md_l_front_data", "md_l_side_data", "md_l_top_data", "md_l_back_data", "md_l_off_data",1342 "lg_r_eyes_data", "lg_r_mouth_data", "lg_r_front_data", "lg_r_side_data", "lg_r_top_data", "lg_r_back_data", "lg_r_off_data",1343 "lg_l_eyes_data", "lg_l_mouth_data", "lg_l_front_data", "lg_l_side_data", "lg_l_top_data", "lg_l_back_data", "lg_l_off_data"];1344 for( var i=0; i < masterDataArray.length; i++){1345 $("#dump-print").append("<p>var " + dataVarNames[i] + "=" + JSON.stringify(masterDataArray[i]) + ";</p>" );1346 console.log(dataVarNames[i] + " SESSION DATA: " + masterDataArray[i]);1347 }1348 // $("#dump-print").html(JSON.stringify(sensorDataSession));1349 $("#dump-print").addClass("active-print");1350 // console.log("SENSOR SESSIONS DATA: " + sensorDataSession);1351 });1352 //load data from js file (JSON or JS object) into sensor session data1353 $('#load-btn').click(function() {1354 console.log("load button");1355 masterDataArray[0] = sh_r_eyes_data1356 masterDataArray[1] = sh_r_mouth_data;1357 masterDataArray[2] = sh_r_front_data;1358 masterDataArray[3] = sh_r_side_data;1359 masterDataArray[4] = sh_r_top_data;1360 masterDataArray[5] = sh_r_back_data;1361 masterDataArray[6] = sh_r_off_data;1362 masterDataArray[7] = sh_l_eyes_data;1363 masterDataArray[8] = sh_l_mouth_data;1364 masterDataArray[9] = sh_l_front_data;1365 masterDataArray[10] = sh_l_side_data;1366 masterDataArray[11] = sh_l_top_data;1367 masterDataArray[12] = sh_l_back_data;1368 masterDataArray[13] = sh_l_off_data;1369 masterDataArray[14] = md_r_eyes_data;1370 masterDataArray[15] = md_r_mouth_data;1371 masterDataArray[16] = md_r_front_data;1372 masterDataArray[17] = md_r_side_data;1373 masterDataArray[18] = md_r_top_data;1374 masterDataArray[19] = md_r_back_data;1375 masterDataArray[20] = md_r_off_data;1376 masterDataArray[21] = md_l_eyes_data;1377 masterDataArray[22] = md_l_mouth_data;1378 masterDataArray[23] = md_l_front_data;1379 masterDataArray[24] = md_l_side_data;1380 masterDataArray[25] = md_l_top_data;1381 masterDataArray[26] = md_l_back_data;1382 masterDataArray[27] = md_l_off_data;1383 masterDataArray[28] = lg_r_eyes_data;1384 masterDataArray[29] = lg_r_mouth_data;1385 masterDataArray[30] = lg_r_front_data;1386 masterDataArray[31] = lg_r_side_data;1387 masterDataArray[32] = lg_r_top_data;1388 masterDataArray[33] = lg_r_back_data;1389 masterDataArray[34] = lg_r_off_data;1390 masterDataArray[35] = lg_l_eyes_data;1391 masterDataArray[36] = lg_l_mouth_data;1392 masterDataArray[37] = lg_l_front_data;1393 masterDataArray[38] = lg_l_side_data;1394 masterDataArray[39] = lg_l_top_data;1395 masterDataArray[40] = lg_l_back_data;1396 masterDataArray[41] = lg_l_off_data;1397 /* masterDataArray[28] = $.merge( lg_r_eyes_data, md_r_eyes_data);1398 masterDataArray[29] = $.merge( lg_r_mouth_data, md_r_mouth_data);1399 masterDataArray[30] = $.merge( lg_r_front_data, md_r_front_data);1400 masterDataArray[31] = $.merge( lg_r_side_data, md_r_side_data);1401 masterDataArray[32] = $.merge( lg_r_top_data, md_r_top_data);1402 masterDataArray[33] = $.merge( lg_r_back_data, md_r_back_data);1403 masterDataArray[34] = $.merge( lg_r_off_data, md_r_off_data);1404 masterDataArray[35] = $.merge( lg_l_eyes_data, md_l_eyes_data);1405 masterDataArray[36] = $.merge( lg_l_mouth_data, md_l_mouth_data);1406 masterDataArray[37] = $.merge( lg_l_front_data, md_l_front_data);1407 masterDataArray[38] = $.merge( lg_l_side_data, md_l_side_data);1408 masterDataArray[39] = $.merge( lg_l_top_data, md_l_top_data);1409 masterDataArray[40] = $.merge( lg_l_back_data, md_l_back_data);1410 masterDataArray[41] = $.merge( lg_l_off_data, md_l_off_data); */1411 //update data count labels1412 for( var i=0; i < masterDataArray.length; i++){1413 $( "span[data='" + i + "']" ).html(masterDataArray[i].length);1414 }1415 });1416}); // end on document load...

Full Screen

Full Screen

TreeGrid.js

Source:TreeGrid.js Github

copy

Full Screen

1describe("Ext.tree.TreeGrid", function() {2 var TreeGridItem = Ext.define(null, {3 extend: 'Ext.data.Model',4 fields: ['f1', 'f2'],5 proxy: {6 type: 'memory'7 }8 }),9 tree,10 view,11 store,12 recordCount,13 treeData = {14 f1: 'root1',15 f2: 'root.a',16 // Add cls. Tests must not throw errors with this present.17 cls: 'test-EXTJS-16367',18 children: [{19 f1: '1',20 f2: 'a',21 children: [{22 f1: '1.1',23 f2: 'a.a',24 leaf: true25 }, {26 f1: '1.2',27 f2: 'a.b',28 leaf: true29 }, {30 f1: '1.3',31 f2: 'a.c',32 leaf: true33 }, {34 f1: '1.4',35 f2: 'a.d',36 leaf: true37 }]38 }, {39 f1: '2',40 f2: 'b',41 children: [{42 f1: '2.1',43 f2: 'b.a',44 leaf: true45 }, {46 f1: '2.2',47 f2: 'b.b',48 leaf: true49 }, {50 f1: '2.3',51 f2: 'b.c',52 leaf: true53 }, {54 f1: '2.4',55 f2: 'b.d',56 leaf: true57 }]58 }, {59 f1: '3',60 f2: 'c',61 children: [{62 f1: '3.1',63 f2: 'c.a',64 leaf: true65 }, {66 f1: '3.2',67 f2: 'c.b',68 leaf: true69 }, {70 f1: '3.3',71 f2: 'c.c',72 leaf: true73 }, {74 f1: '3.4',75 f2: 'c.d',76 leaf: true77 }]78 }, {79 f1: '4',80 f2: 'd',81 children: [{82 f1: '4.1',83 f2: 'd.a',84 leaf: true85 }, {86 f1: '4.2',87 f2: 'd.b',88 leaf: true89 }, {90 f1: '4.3',91 f2: 'd.c',92 leaf: true93 }, {94 f1: '4.4',95 f2: 'd.d',96 leaf: true97 }]98 }, {99 f1: '5',100 f2: 'e',101 children: [{102 f1: '5.1',103 f2: 'e.a',104 leaf: true105 }, {106 f1: '5.2',107 f2: 'e.b',108 leaf: true109 }, {110 f1: '5.3',111 f2: 'e.c',112 leaf: true113 }, {114 f1: '5.4',115 f2: 'e.d',116 leaf: true117 }]118 }, {119 f1: '6',120 f2: 'f',121 children: [{122 f1: '6.1',123 f2: 'f.a',124 leaf: true125 }, {126 f1: '6.2',127 f2: 'f.b',128 leaf: true129 }, {130 f1: '6.3',131 f2: 'f.c',132 leaf: true133 }, {134 f1: '6.4',135 f2: 'f.d',136 leaf: true137 }]138 }]139 },140 synchronousLoad = true,141 treeStoreLoad = Ext.data.TreeStore.prototype.load,142 loadStore;143 144 function makeTreeGrid(cfg, storeCfg) {145 tree = new Ext.tree.Panel(Ext.apply({146 animate: false,147 renderTo: Ext.getBody(),148 store: store = new Ext.data.TreeStore(Ext.apply({149 model: TreeGridItem,150 root: Ext.clone(treeData)151 }, storeCfg)),152 trailingBufferZone: 1000,153 leadingBufferZone: 1000,154 width: 200,155 columns: [{156 xtype: 'treecolumn',157 text: 'F1',158 dataIndex: 'f1',159 width: 100160 }, {161 text: 'F2',162 dataIndex: 'f2',163 flex: 1164 }]165 }, cfg));166 view = tree.getView();167 }168 beforeEach(function() {169 // Override so that we can control asynchronous loading170 loadStore = Ext.data.TreeStore.prototype.load = function() {171 treeStoreLoad.apply(this, arguments);172 if (synchronousLoad) {173 this.flushLoad.apply(this, arguments);174 }175 return this;176 };177 });178 afterEach(function(){179 // Undo the overrides.180 Ext.data.TreeStore.prototype.load = treeStoreLoad;181 Ext.destroy(tree);182 });183 184 describe('Model mutation', function() {185 it('should not have to render a whole row, it should update innerHTML of cell', function() {186 makeTreeGrid();187 // Test cls config188 expect(view.getCellByPosition({row:0, column: 0}).hasCls('test-EXTJS-16367')).toBe(true);189 var createRowSpy = spyOn(view, 'createRowElement').andCallThrough();190 store.getAt(0).set({191 f1: 'ploot',192 f2: 'gronk'193 });194 // MUST not have created a bew row, we must have just updated the text within the cell195 expect(createRowSpy).not.toHaveBeenCalled();196 });197 });198 describe('autoloading', function() {199 it('should not autoload the store if the root is visible', function() {200 var loadCount = 0;201 // rootVisible defaults to true, so no autoload202 makeTreeGrid({203 columns: [{204 xtype: 'treecolumn',205 text: 'F1',206 dataIndex: 'f1',207 width: 100208 }],209 store: {210 listeners: {211 load: function() {212 loadCount++;213 }214 }215 }216 });217 expect(loadCount).toBe(0);218 });219 it('should not autoload the store if the root is visible and there is a locked column', function() {220 var loadCount = 0;221 // rootVisible defaults to true, so no autoload222 makeTreeGrid({223 columns: [{224 xtype: 'treecolumn',225 text: 'F1',226 dataIndex: 'f1',227 width: 100,228 locked: true229 }],230 store: {231 listeners: {232 load: function() {233 loadCount++;234 }235 }236 }237 });238 expect(loadCount).toBe(0);239 });240 it('should autoload the store if the root is visible', function() {241 var loadCount = 0;242 // rootVisible set to false, so autoload so that user sees the tree content243 makeTreeGrid({244 rootVisible: false,245 columns: [{246 xtype: 'treecolumn',247 text: 'F1',248 dataIndex: 'f1',249 width: 100250 }],251 store: {252 proxy: 'memory',253 listeners: {254 load: function() {255 loadCount++;256 }257 }258 }259 });260 expect(loadCount).toBe(1);261 });262 it('should autoload the store if the root is visible and there is a locked column', function() {263 var loadCount = 0;264 // rootVisible set to false, so autoload so that user sees the tree content265 makeTreeGrid({266 rootVisible: false,267 columns: [{268 xtype: 'treecolumn',269 text: 'F1',270 dataIndex: 'f1',271 width: 100,272 locked: true273 }],274 store: {275 proxy: 'memory',276 listeners: {277 load: function() {278 loadCount++;279 }280 }281 }282 });283 expect(loadCount).toBe(1);284 });285 });286 describe("Buffered rendering", function() {287 var rootNode;288 beforeEach(function() {289 makeTreeGrid({290 height: 45,291 plugins: Ext.create('Ext.grid.plugin.BufferedRenderer', {292 trailingBufferZone: 1,293 leadingBufferZone: 1294 })295 });296 tree.expandAll();297 recordCount = tree.view.store.getCount();298 rootNode = tree.getRootNode();299 });300 it("should not render every node", function() {301 expect(recordCount).toEqual(31);302 // The view's Composite element should only contain the visible rows plus buffer zones.303 // Should be less than the total node count in the Tree structure.304 expect(tree.view.all.getCount()).toBeLessThan(recordCount);305 });306 it("should not not scroll upon node expand", function() {307 tree.collapseAll();308 rootNode.expand();309 tree.view.setScrollY(40);310 tree.getRootNode().childNodes[1].expand();311 // Expanding a node should not scroll.312 expect(tree.view.getScrollY()).toEqual(40);313 });314 });315 describe('buffered rendering with locking and rootVisible: false', function() {316 var rootNode;317 beforeEach(function() {318 makeTreeGrid({319 renderTo: Ext.getBody(),320 height: 120,321 store: new Ext.data.TreeStore({322 model: TreeGridItem,323 root: {324 f1: 'Root',325 f2: 'root',326 children: [{327 f1: 'c0',328 f2: 'c0',329 leaf: true330 }, {331 f1: 'c1',332 f2: 'c1',333 leaf: true334 }, {335 f1: 'c2',336 f2: 'c2',337 leaf: true338 }]339 }340 }),341 plugins: Ext.create('Ext.grid.plugin.BufferedRenderer', {342 trailingBufferZone: 1,343 leadingBufferZone: 1344 }),345 columns: [{346 xtype: 'treecolumn',347 text: 'F1',348 dataIndex: 'f1',349 width: 100,350 locked: true351 }, {352 text: 'F2',353 dataIndex: 'f2',354 flex: 1355 }],356 rootVisible: false357 });358 recordCount = tree.lockedGrid.view.store.getCount();359 rootNode = tree.getRootNode();360 });361 it('should work when inserting a node at the top', function() {362 expect(tree.lockedGrid.view.all.getCount()).toEqual(3);363 expect(tree.normalGrid.view.all.getCount()).toEqual(3);364 rootNode.insertBefore({text:'Top'}, rootNode.childNodes[0]);365 expect(tree.lockedGrid.view.all.getCount()).toEqual(4);366 expect(tree.normalGrid.view.all.getCount()).toEqual(4);367 });368 });369 describe("Buffered rendering and locking", function() {370 var rootNode;371 beforeEach(function() {372 makeTreeGrid({373 height: 45,374 plugins: Ext.create('Ext.grid.plugin.BufferedRenderer', {375 trailingBufferZone: 1,376 leadingBufferZone: 1377 }),378 columns: [{379 xtype: 'treecolumn',380 text: 'F1',381 dataIndex: 'f1',382 width: 100,383 locked: true384 }, {385 text: 'F2',386 dataIndex: 'f2',387 flex: 1388 }]389 });390 tree.expandAll();391 recordCount = tree.lockedGrid.view.store.getCount();392 rootNode = tree.getRootNode();393 });394 it("should not render every node", function() {395 var lockedTree = tree.lockedGrid,396 normalGrid = tree.normalGrid,397 viewSize = lockedTree.view.all.getCount();398 expect(recordCount).toEqual(31);399 // The view's Composite element should only contain the visible rows plus buffer zones.400 // Should be less than the total node count in the Tree structure.401 expect(viewSize).toBeLE(recordCount);402 expect(normalGrid.view.all.getCount()).toEqual(viewSize);403 });404 it('should sync scroll positions between the two sides', function() {405 var lockedTree = tree.lockedGrid,406 normalGrid = tree.normalGrid,407 lockedView = lockedTree.view,408 normalView = normalGrid.view;409 tree.collapseAll();410 rootNode.expand();411 normalView.setScrollY(30);412 waits(200); // Wait for the scroll listener (deferred to next animation Frame)413 runs(function() {414 expect(lockedView.getScrollY()).toEqual(30);415 // Now, at 120px high, the entire tree is rendered, scrolling will not triggert action by the buffered renderer416 // Scrolling should still sync417 tree.setHeight(120);418 normalView.setScrollY(45);419 waits(200); // Wait for the scroll listener (deferred to next animation Frame)420 runs(function() {421 expect(lockedView.getScrollY()).toEqual(45);422 rootNode.childNodes[2].expand();423 // Root node, its 6 children, and child[2]'s 4 children: 11 records in NodeStore424 expect(normalView.store.getCount()).toEqual(11);425 // But scroll position should not change426 expect(lockedView.el.dom.scrollTop).toEqual(45);427 });428 });429 });430 });431 432 describe('reconfigure', function() {433 it('should allow reconfigure', function() {434 var cols = [{435 xtype: 'treecolumn',436 text: 'Task',437 flex: 1,438 dataIndex: 'task'439 }, {440 text: 'URL',441 flex: 1,442 sortable: false,443 dataIndex: 'url'444 }];445 var cols2 = [{446 xtype: 'treecolumn',447 text: 'New Task',448 flex: 1,449 dataIndex: 'new_task'450 }, {451 text: 'New URL',452 flex: 1,453 sortable: false,454 dataIndex: 'new_url'455 }];456 Ext.define('ReconfigureTestTask', {457 extend: 'Ext.data.Model',458 fields: [{459 name: 'task',460 type: 'string'461 }, {462 name: 'url',463 type: 'string'464 }]465 });466 Ext.define('ReconfigureTestNewTask', {467 extend: 'Ext.data.Model',468 fields: [{469 name: 'new_task',470 type: 'string'471 }, {472 name: 'new_url',473 type: 'string'474 }]475 });476 var store = Ext.create('Ext.data.TreeStore', {477 model: 'ReconfigureTestTask',478 root: {479 expanded: true,480 children: [{481 task: 'task1',482 url: 'url1',483 expanded: true,484 children: [{485 task: 'task1.1',486 url: 'url1.1',487 leaf: true488 }]489 }, {490 task: 'task2',491 url: 'url2',492 expanded: true,493 children: [{494 task: 'task2.1',495 url: 'url2.1',496 leaf: true497 }]498 }]499 }500 });501 var store2 = Ext.create('Ext.data.TreeStore', {502 model: 'ReconfigureTestNewTask',503 root: {504 expanded: true,505 children: [{506 new_task: 'new-task1',507 new_url: 'new-url1',508 expanded: true,509 children: [{510 new_task: 'new-task1.1',511 new_url: 'new-url1.1',512 leaf: true513 }]514 }, {515 new_task: 'new-task2',516 new_url: 'new-url2',517 expanded: true,518 children: [{519 new_task: 'new-task2.1',520 new_url: 'new-url2.1',521 leaf: true522 }]523 }]524 }525 });526 var myTree = Ext.create('Ext.tree.Panel', {527 title: 'treegrid',528 width: 600,529 height: 300,530 renderTo: Ext.getBody(),531 collapsible: true,532 rootVisible: false,533 useArrows: true,534 store: store,535 multiSelect: true,536 columns: cols537 }),538 root = myTree.getRootNode();539 expect(root.childNodes[0].data.task).toEqual('task1');540 expect(root.childNodes[0].data.url).toEqual('url1');541 expect(root.childNodes[0].childNodes[0].data.task).toEqual('task1.1');542 expect(root.childNodes[0].childNodes[0].data.url).toEqual('url1.1');543 expect(root.childNodes[1].data.task).toEqual('task2');544 expect(root.childNodes[1].data.url).toEqual('url2');545 expect(root.childNodes[1].childNodes[0].data.task).toEqual('task2.1');546 expect(root.childNodes[1].childNodes[0].data.url).toEqual('url2.1');547 myTree.reconfigure(store2, cols2);548 root = myTree.getRootNode();549 expect(root.childNodes[0].data.new_task).toEqual('new-task1');550 expect(root.childNodes[0].data.new_url).toEqual('new-url1');551 expect(root.childNodes[0].childNodes[0].data.new_task).toEqual('new-task1.1');552 expect(root.childNodes[0].childNodes[0].data.new_url).toEqual('new-url1.1');553 expect(root.childNodes[1].data.new_task).toEqual('new-task2');554 expect(root.childNodes[1].data.new_url).toEqual('new-url2');555 expect(root.childNodes[1].childNodes[0].data.new_task).toEqual('new-task2.1');556 expect(root.childNodes[1].childNodes[0].data.new_url).toEqual('new-url2.1');557 558 myTree.destroy();559 Ext.undefine('ReconfigureTestTask');560 Ext.undefine('ReconfigureTestNewTask');561 });562 });563 ...

Full Screen

Full Screen

sparse_feature_cross_op_test.py

Source:sparse_feature_cross_op_test.py Github

copy

Full Screen

1# Copyright 2016 The TensorFlow Authors. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14# ==============================================================================15"""Tests for tf.contrib.layers.sparse_feature_cross."""16from __future__ import absolute_import17from __future__ import division18from __future__ import print_function19import numpy20from tensorflow.contrib import layers21from tensorflow.contrib.layers.python.ops import sparse_feature_cross_op22from tensorflow.python.client import session23from tensorflow.python.framework import constant_op24from tensorflow.python.framework import dtypes25from tensorflow.python.framework import sparse_tensor26from tensorflow.python.ops import sparse_ops27from tensorflow.python.platform import test28class SparseCrossOpTest(test.TestCase):29 def test_simple(self):30 """Tests a simple scenario.31 """32 op = sparse_feature_cross_op.sparse_feature_cross([33 self._sparse_tensor([['batch1-FC1-F1'],34 ['batch2-FC1-F1', 'batch2-FC1-F2']]),35 self._sparse_tensor([['batch1-FC2-F1'],36 ['batch2-FC2-F1', 'batch2-FC2-F2']])37 ])38 expected_out = self._sparse_tensor([['batch1-FC1-F1_X_batch1-FC2-F1'], [39 'batch2-FC1-F1_X_batch2-FC2-F1', 'batch2-FC1-F1_X_batch2-FC2-F2',40 'batch2-FC1-F2_X_batch2-FC2-F1', 'batch2-FC1-F2_X_batch2-FC2-F2'41 ]])42 with self.test_session() as sess:43 self._assert_sparse_tensor_equals(expected_out, sess.run(op))44 def test_dense(self):45 """Tests only dense inputs.46 """47 op = sparse_feature_cross_op.sparse_feature_cross([48 constant_op.constant([['batch1-FC1-F1', 'batch1-FC1-F2'],49 ['batch2-FC1-F1', 'batch2-FC1-F2']],50 dtypes.string),51 constant_op.constant([['batch1-FC2-F1', 'batch1-FC2-F2'],52 ['batch2-FC2-F1', 'batch2-FC2-F2']],53 dtypes.string),54 ])55 expected_out = self._sparse_tensor([[56 'batch1-FC1-F1_X_batch1-FC2-F1', 'batch1-FC1-F1_X_batch1-FC2-F2',57 'batch1-FC1-F2_X_batch1-FC2-F1', 'batch1-FC1-F2_X_batch1-FC2-F2'58 ], [59 'batch2-FC1-F1_X_batch2-FC2-F1', 'batch2-FC1-F1_X_batch2-FC2-F2',60 'batch2-FC1-F2_X_batch2-FC2-F1', 'batch2-FC1-F2_X_batch2-FC2-F2'61 ]])62 with self.test_session() as sess:63 self._assert_sparse_tensor_equals(expected_out, sess.run(op))64 def test_integer_mixed_string_sparse(self):65 """Tests mixed type."""66 op = sparse_feature_cross_op.sparse_feature_cross([67 self._sparse_tensor([[11], [333, 55555]]),68 self._sparse_tensor([['batch1-FC2-F1'],69 ['batch2-FC2-F1', 'batch2-FC2-F2']])70 ])71 expected_out = self._sparse_tensor([['11_X_batch1-FC2-F1'], [72 '333_X_batch2-FC2-F1', '333_X_batch2-FC2-F2', '55555_X_batch2-FC2-F1',73 '55555_X_batch2-FC2-F2'74 ]])75 with self.test_session() as sess:76 self._assert_sparse_tensor_equals(expected_out, sess.run(op))77 def test_integer_mixed_string_dense(self):78 """Tests mixed dense inputs.79 """80 op = sparse_feature_cross_op.sparse_feature_cross([81 constant_op.constant([[11, 333], [55555, 999999]], dtypes.int64),82 constant_op.constant([['batch1-FC2-F1', 'batch1-FC2-F2'],83 ['batch2-FC2-F1', 'batch2-FC2-F2']],84 dtypes.string),85 ])86 expected_out = self._sparse_tensor([[87 '11_X_batch1-FC2-F1', '11_X_batch1-FC2-F2', '333_X_batch1-FC2-F1',88 '333_X_batch1-FC2-F2'89 ], [90 '55555_X_batch2-FC2-F1', '55555_X_batch2-FC2-F2',91 '999999_X_batch2-FC2-F1', '999999_X_batch2-FC2-F2'92 ]])93 with self.test_session() as sess:94 self._assert_sparse_tensor_equals(expected_out, sess.run(op))95 def test_sparse_cross_dense(self):96 """Tests sparse and dense inputs.97 """98 op = sparse_feature_cross_op.sparse_feature_cross([99 self._sparse_tensor([['batch1-FC1-F1'],100 ['batch2-FC1-F1', 'batch2-FC1-F2']]),101 constant_op.constant([['batch1-FC2-F1', 'batch1-FC2-F2'],102 ['batch2-FC2-F1', 'batch2-FC2-F2']],103 dtypes.string),104 ])105 expected_out = self._sparse_tensor(106 [['batch1-FC1-F1_X_batch1-FC2-F1', 'batch1-FC1-F1_X_batch1-FC2-F2'], [107 'batch2-FC1-F1_X_batch2-FC2-F1', 'batch2-FC1-F1_X_batch2-FC2-F2',108 'batch2-FC1-F2_X_batch2-FC2-F1', 'batch2-FC1-F2_X_batch2-FC2-F2'109 ]])110 with self.test_session() as sess:111 self._assert_sparse_tensor_equals(expected_out, sess.run(op))112 def test_integer_sparse_input(self):113 """Tests mixed type sparse and dense inputs."""114 op = sparse_feature_cross_op.sparse_feature_cross([115 self._sparse_tensor([[11], [333, 5555]]),116 constant_op.constant([['batch1-FC2-F1', 'batch1-FC2-F2'],117 ['batch2-FC2-F1', 'batch2-FC2-F2']],118 dtypes.string),119 ])120 expected_out = self._sparse_tensor(121 [['11_X_batch1-FC2-F1', '11_X_batch1-FC2-F2'], [122 '333_X_batch2-FC2-F1', '333_X_batch2-FC2-F2',123 '5555_X_batch2-FC2-F1', '5555_X_batch2-FC2-F2'124 ]])125 with self.test_session() as sess:126 self._assert_sparse_tensor_equals(expected_out, sess.run(op))127 def test_permutation_3x3x3(self):128 """Tests 3x3x3 permutation.129 """130 op = sparse_feature_cross_op.sparse_feature_cross([131 self._sparse_tensor(132 [['batch1-FC1-F1', 'batch1-FC1-F2', 'batch1-FC1-F3']]),133 self._sparse_tensor(134 [['batch1-FC2-F1', 'batch1-FC2-F2', 'batch1-FC2-F3']]),135 self._sparse_tensor(136 [['batch1-FC3-F1', 'batch1-FC3-F2', 'batch1-FC3-F3']])137 ])138 expected_out = self._sparse_tensor([[139 'batch1-FC1-F1_X_batch1-FC2-F1_X_batch1-FC3-F1',140 'batch1-FC1-F1_X_batch1-FC2-F1_X_batch1-FC3-F2',141 'batch1-FC1-F1_X_batch1-FC2-F1_X_batch1-FC3-F3',142 'batch1-FC1-F1_X_batch1-FC2-F2_X_batch1-FC3-F1',143 'batch1-FC1-F1_X_batch1-FC2-F2_X_batch1-FC3-F2',144 'batch1-FC1-F1_X_batch1-FC2-F2_X_batch1-FC3-F3',145 'batch1-FC1-F1_X_batch1-FC2-F3_X_batch1-FC3-F1',146 'batch1-FC1-F1_X_batch1-FC2-F3_X_batch1-FC3-F2',147 'batch1-FC1-F1_X_batch1-FC2-F3_X_batch1-FC3-F3',148 'batch1-FC1-F2_X_batch1-FC2-F1_X_batch1-FC3-F1',149 'batch1-FC1-F2_X_batch1-FC2-F1_X_batch1-FC3-F2',150 'batch1-FC1-F2_X_batch1-FC2-F1_X_batch1-FC3-F3',151 'batch1-FC1-F2_X_batch1-FC2-F2_X_batch1-FC3-F1',152 'batch1-FC1-F2_X_batch1-FC2-F2_X_batch1-FC3-F2',153 'batch1-FC1-F2_X_batch1-FC2-F2_X_batch1-FC3-F3',154 'batch1-FC1-F2_X_batch1-FC2-F3_X_batch1-FC3-F1',155 'batch1-FC1-F2_X_batch1-FC2-F3_X_batch1-FC3-F2',156 'batch1-FC1-F2_X_batch1-FC2-F3_X_batch1-FC3-F3',157 'batch1-FC1-F3_X_batch1-FC2-F1_X_batch1-FC3-F1',158 'batch1-FC1-F3_X_batch1-FC2-F1_X_batch1-FC3-F2',159 'batch1-FC1-F3_X_batch1-FC2-F1_X_batch1-FC3-F3',160 'batch1-FC1-F3_X_batch1-FC2-F2_X_batch1-FC3-F1',161 'batch1-FC1-F3_X_batch1-FC2-F2_X_batch1-FC3-F2',162 'batch1-FC1-F3_X_batch1-FC2-F2_X_batch1-FC3-F3',163 'batch1-FC1-F3_X_batch1-FC2-F3_X_batch1-FC3-F1',164 'batch1-FC1-F3_X_batch1-FC2-F3_X_batch1-FC3-F2',165 'batch1-FC1-F3_X_batch1-FC2-F3_X_batch1-FC3-F3'166 ]])167 with self.test_session() as sess:168 self._assert_sparse_tensor_equals(expected_out, sess.run(op))169 def test_permutation_3x1x2(self):170 """Tests 3x1x2 permutation.171 """172 op = sparse_feature_cross_op.sparse_feature_cross([173 self._sparse_tensor(174 [['batch1-FC1-F1', 'batch1-FC1-F2', 'batch1-FC1-F3']]),175 self._sparse_tensor([['batch1-FC2-F1']]),176 self._sparse_tensor([['batch1-FC3-F1', 'batch1-FC3-F2']])177 ])178 expected_out = self._sparse_tensor([[179 'batch1-FC1-F1_X_batch1-FC2-F1_X_batch1-FC3-F1',180 'batch1-FC1-F1_X_batch1-FC2-F1_X_batch1-FC3-F2',181 'batch1-FC1-F2_X_batch1-FC2-F1_X_batch1-FC3-F1',182 'batch1-FC1-F2_X_batch1-FC2-F1_X_batch1-FC3-F2',183 'batch1-FC1-F3_X_batch1-FC2-F1_X_batch1-FC3-F1',184 'batch1-FC1-F3_X_batch1-FC2-F1_X_batch1-FC3-F2'185 ]])186 with self.test_session() as sess:187 self._assert_sparse_tensor_equals(expected_out, sess.run(op))188 def test_large_batch(self):189 """Tests with large batch size to force multithreding.190 """191 batch_size = 5000192 col1 = []193 col2 = []194 col3 = []195 for b in range(batch_size):196 col1.append(197 ['batch%d-FC1-F1' % b, 'batch%d-FC1-F2' % b, 'batch%d-FC1-F3' % b])198 col2.append(['batch%d-FC2-F1' % b])199 col3.append(['batch%d-FC3-F1' % b, 'batch%d-FC3-F2' % b])200 op = sparse_feature_cross_op.sparse_feature_cross([201 self._sparse_tensor(col1), self._sparse_tensor(col2),202 self._sparse_tensor(col3)203 ])204 col_out = []205 for b in range(batch_size):206 col_out.append([207 'batch%d-FC1-F1_X_batch%d-FC2-F1_X_batch%d-FC3-F1' % (b, b, b),208 'batch%d-FC1-F1_X_batch%d-FC2-F1_X_batch%d-FC3-F2' % (b, b, b),209 'batch%d-FC1-F2_X_batch%d-FC2-F1_X_batch%d-FC3-F1' % (b, b, b),210 'batch%d-FC1-F2_X_batch%d-FC2-F1_X_batch%d-FC3-F2' % (b, b, b),211 'batch%d-FC1-F3_X_batch%d-FC2-F1_X_batch%d-FC3-F1' % (b, b, b),212 'batch%d-FC1-F3_X_batch%d-FC2-F1_X_batch%d-FC3-F2' % (b, b, b)213 ])214 expected_out = self._sparse_tensor(col_out)215 with self.test_session() as sess:216 self._assert_sparse_tensor_equals(expected_out, sess.run(op))217 def test_one_column_empty(self):218 """Tests when one column is empty.219 The crossed tensor should be empty.220 """221 op = sparse_feature_cross_op.sparse_feature_cross([222 self._sparse_tensor([['batch1-FC1-F1', 'batch1-FC1-F2']]),223 self._sparse_tensor([], 1),224 self._sparse_tensor([['batch1-FC3-F1', 'batch1-FC3-F2']])225 ])226 with self.test_session() as sess:227 self._assert_sparse_tensor_empty(sess.run(op))228 def test_some_columns_empty(self):229 """Tests when more than one columns are empty.230 Cross for the corresponding batch should be empty.231 """232 op = sparse_feature_cross_op.sparse_feature_cross([233 self._sparse_tensor([['batch1-FC1-F1', 'batch1-FC1-F2']], 2),234 self._sparse_tensor([['batch1-FC2-F1'], ['batch2-FC2-F1']], 2),235 self._sparse_tensor([['batch1-FC3-F1', 'batch1-FC3-F2']], 2)236 ])237 expected_out = self._sparse_tensor([[238 'batch1-FC1-F1_X_batch1-FC2-F1_X_batch1-FC3-F1',239 'batch1-FC1-F1_X_batch1-FC2-F1_X_batch1-FC3-F2',240 'batch1-FC1-F2_X_batch1-FC2-F1_X_batch1-FC3-F1',241 'batch1-FC1-F2_X_batch1-FC2-F1_X_batch1-FC3-F2'242 ]], 2)243 with self.test_session() as sess:244 self._assert_sparse_tensor_equals(expected_out, sess.run(op))245 def test_all_columns_empty(self):246 """Tests when all columns are empty.247 The crossed tensor should be empty.248 """249 op = sparse_feature_cross_op.sparse_feature_cross([250 self._sparse_tensor([]), self._sparse_tensor([]),251 self._sparse_tensor([])252 ])253 with self.test_session() as sess:254 self._assert_sparse_tensor_empty(sess.run(op))255 def test_hashed_output_zero_bucket(self):256 """Tests a simple scenario.257 """258 op = sparse_feature_cross_op.sparse_feature_cross(259 [260 self._sparse_tensor([['batch1-FC1-F1']]),261 self._sparse_tensor([['batch1-FC2-F1']]),262 self._sparse_tensor([['batch1-FC3-F1']])263 ],264 hashed_output=True)265 # Check actual hashed output to prevent unintentional hashing changes.266 expected_out = self._sparse_tensor([[3735511728867393167]])267 with self.test_session() as sess:268 self._assert_sparse_tensor_equals(expected_out, sess.run(op))269 def test_hashed_output_zero_bucket_v2(self):270 """Tests a simple scenario.271 """272 op = sparse_feature_cross_op.sparse_feature_cross(273 [274 self._sparse_tensor([['batch1-FC1-F1']]),275 self._sparse_tensor([['batch1-FC2-F1']]),276 self._sparse_tensor([['batch1-FC3-F1']])277 ],278 hashed_output=True,279 hash_key=layers.SPARSE_FEATURE_CROSS_DEFAULT_HASH_KEY)280 # Check actual hashed output to prevent unintentional hashing changes.281 expected_out = self._sparse_tensor([[1971693436396284976]])282 with self.test_session() as sess:283 self._assert_sparse_tensor_equals(expected_out, sess.run(op))284 # TODO(sibyl-Aix6ihai): Add benchmark to compare Hashed vs Non-hashed.285 def test_hashed_output(self):286 """Tests a simple scenario.287 """288 op = sparse_feature_cross_op.sparse_feature_cross(289 [290 self._sparse_tensor([['batch1-FC1-F1']]),291 self._sparse_tensor([['batch1-FC2-F1']]),292 self._sparse_tensor([['batch1-FC3-F1']])293 ],294 hashed_output=True,295 num_buckets=100)296 # Check actual hashed output to prevent unintentional hashing changes.297 expected_out = self._sparse_tensor([[74]])298 with self.test_session() as sess:299 self._assert_sparse_tensor_equals(expected_out, sess.run(op))300 def test_hashed_output_v2(self):301 """Tests a simple scenario.302 """303 op = sparse_feature_cross_op.sparse_feature_cross(304 [305 self._sparse_tensor([['batch1-FC1-F1']]),306 self._sparse_tensor([['batch1-FC2-F1']]),307 self._sparse_tensor([['batch1-FC3-F1']])308 ],309 hashed_output=True,310 num_buckets=100,311 hash_key=layers.SPARSE_FEATURE_CROSS_DEFAULT_HASH_KEY)312 # Check actual hashed output to prevent unintentional hashing changes.313 expected_out = self._sparse_tensor([[83]])314 with self.test_session() as sess:315 self._assert_sparse_tensor_equals(expected_out, sess.run(op))316 def test_hashed_output_v1_has_collision(self):317 """Tests the old version of the fingerprint concatenation has collisions.318 """319 # The last 10 bits of 359 and 1024+359 are identical.320 # As a result, all the crosses collide.321 t1 = constant_op.constant([[359], [359 + 1024]])322 t2 = constant_op.constant([list(range(10)), list(range(10))])323 cross = sparse_feature_cross_op.sparse_feature_cross(324 [t2, t1], hashed_output=True, num_buckets=1024)325 cross_dense = sparse_ops.sparse_tensor_to_dense(cross)326 with session.Session():327 values = cross_dense.eval()328 self.assertTrue(numpy.equal(values[0], values[1]).all())329 def test_hashed_output_v2_has_no_collision(self):330 """Tests the new version of the fingerprint concatenation has no collisions.331 """332 # Although the last 10 bits of 359 and 1024+359 are identical.333 # As a result, all the crosses shouldn't collide.334 t1 = constant_op.constant([[359], [359 + 1024]])335 t2 = constant_op.constant([list(range(10)), list(range(10))])336 cross = sparse_feature_cross_op.sparse_feature_cross(337 [t2, t1],338 hashed_output=True,339 num_buckets=1024,340 hash_key=layers.SPARSE_FEATURE_CROSS_DEFAULT_HASH_KEY)341 cross_dense = sparse_ops.sparse_tensor_to_dense(cross)342 with session.Session():343 values = cross_dense.eval()344 self.assertTrue(numpy.not_equal(values[0], values[1]).all())345 def test_hashed_3x1x2(self):346 """Tests 3x1x2 permutation with hashed output.347 """348 op = sparse_feature_cross_op.sparse_feature_cross(349 [350 self._sparse_tensor(351 [['batch1-FC1-F1', 'batch1-FC1-F2', 'batch1-FC1-F3']]),352 self._sparse_tensor([['batch1-FC2-F1']]),353 self._sparse_tensor([['batch1-FC3-F1', 'batch1-FC3-F2']])354 ],355 hashed_output=True,356 num_buckets=1000)357 with self.test_session() as sess:358 out = sess.run(op)359 self.assertEqual(6, len(out.values))360 self.assertAllEqual([[0, i] for i in range(6)], out.indices)361 self.assertTrue(all(x < 1000 and x >= 0 for x in out.values))362 all_values_are_different = len(out.values) == len(set(out.values))363 self.assertTrue(all_values_are_different)364 def _assert_sparse_tensor_empty(self, sp):365 self.assertEquals(0, sp.indices.size)366 self.assertEquals(0, sp.values.size)367 # TODO(zakaria): check if we can ignore the first dim of the shape.368 self.assertEquals(0, sp.dense_shape[1])369 def _assert_sparse_tensor_equals(self, sp1, sp2):370 self.assertAllEqual(sp1.indices.eval(), sp2.indices)371 self.assertAllEqual(sp1.values.eval(), sp2.values)372 self.assertAllEqual(sp1.dense_shape.eval(), sp2.dense_shape)373 def _sparse_tensor(self, data, batch_size=-1):374 """Generates a SparseTensor.375 Args:376 data: Should be a list of list of strings or int64. Each item of the outer377 list represents a batch. Each item of the batch is a feature of a378 specific feature column.379 batch_size: optional batch size, especially for cases when data has no380 entry for some batches.381 Returns:382 A SparseTensor.383 """384 indices = []385 values = []386 max_col_count = 0387 for batch, batch_ix in zip(data, range(len(data))):388 for column, column_ix in zip(batch, range(len(batch))):389 indices.append([batch_ix, column_ix])390 values.append(column)391 max_col_count = max(max_col_count, column_ix + 1)392 shape = [batch_size if batch_size != -1 else len(data), max_col_count]393 value_type = (dtypes.string if not values or isinstance(values[0], str) else394 dtypes.int64)395 return sparse_tensor.SparseTensor(396 constant_op.constant(indices, dtypes.int64, [len(indices), 2]),397 constant_op.constant(values, value_type, [len(indices)]),398 constant_op.constant(shape, dtypes.int64))399if __name__ == '__main__':...

Full Screen

Full Screen

general.js

Source:general.js Github

copy

Full Screen

1truncate_constants: {2 options = {3 features : "ASTREL"4 };5 input: {6 function chunkData() { 7 var x = "very long string, very long string, very long string, very long string, very long string, very long string, very long string, very long string, very long string, very long string, very long string, very long string";8 }9 }10 expect: {11 '{12 "query":[13 {"a": 0, "b": 1, "f2": ":VarDef[1]-String"}14 ],15 "assign":[16 {"v": 0, "inf": "x"},17 {"v": 1, "giv": "very%20long%20string%2C%20very%20long%20string%2C%20very%20long%20string%2C%20very%20long%20"}18 ]19 }'20 }21}22escape_constants: {23 options = {24 features : "ASTREL"25 };26 input: {27 function chunkData() { 28 var x = '"quoted text"';29 }30 }31 expect: {32 '{33 "query":[34 {"a": 0, "b": 1, "f2": ":VarDef[1]-String"}35 ],36 "assign":[37 {"v": 0, "inf": "x"},38 {"v": 1, "giv": "%22quoted%20text%22"}39 ]40 }'41 }42}43var_scope: {44 options = {45 features : "ASTREL"46 };47 input: {48 function chunkData() { 49 var a = 1;50 var b = 2;51 var x = a + b;52 x = a + b;53 }54 }55 expect: {56 '{57 "query":[58 {"a": 0, "b": 1, "f2": ":VarDef[1]-Number"},59 {"a": 2, "b": 3, "f2": ":VarDef[1]-Number"},60 {"a": 4, "b": 0, "f2": ":VarDef[1]Binary+[0]"},61 {"a": 4, "b": 2, "f2": ":VarDef[1]Binary+[1]"},62 {"a": 0, "b": 2, "f2": ":Binary+[1]"},63 {"a": 4, "b": 0, "f2": ":Assign=[1]Binary+[0]"},64 {"a": 4, "b": 2, "f2": ":Assign=[1]Binary+[1]"}65 ],66 "assign":[67 {"v": 0, "inf": "a"},68 {"v": 1, "giv": "1"},69 {"v": 2, "inf": "b"},70 {"v": 3, "giv": "2"},71 {"v": 4, "inf": "x"}72 ]73 }'74 }75}76this_scope: {77 options = {78 features : "ASTREL"79 };80 input: {81 function chunkData(a) {82 this.x = a; 83 }84 function chunkData2(a) {85 this.x = a; 86 }87 }88 expect: {89 '{90 "query":[91 {"a": 0, "b": 1, "f2": ":Assign=[1]"}, 92 {"a": 2, "b": 1, "f2": "Dot[0]:Assign=[1]"},93 {"a": 0, "b": 3, "f2": ":Assign=[1]"}, 94 {"a": 2, "b": 3, "f2": "Dot[0]:Assign=[1]"}95 ],96 "assign":[97 {"v": 0, "giv": "x"},98 {"v": 1, "inf": "a"},99 {"v": 2, "giv": "this"},100 {"v": 3, "inf": "a"} 101 ]102 }'103 }104}105this_is_given: {106 options = {107 features : "ASTREL"108 };109 input: {110 function chunkData(a) {111 this.x = a; 112 }113 }114 expect: {115 '{116 "query":[117 {"a": 0, "b": 1, "f2": ":Assign=[1]"}, 118 {"a": 2, "b": 1, "f2": "Dot[0]:Assign=[1]"}119 ],120 "assign":[121 {"v": 0, "giv": "x"},122 {"v": 1, "inf": "a"},123 {"v": 2, "giv": "this"}124 ]125 }'126 }127}128this_attr_scope: {129 options = {130 features : "ASTREL"131 };132 input: {133 function chunkData(a,b) {134 this.x = a;135 this.x = b;136 }137 }138 expect: {139 '{140 "query":[141 {"a": 0, "b": 1, "f2": ":Assign=[1]"}, 142 {"a": 2, "b": 1, "f2": "Dot[0]:Assign=[1]"},143 {"a": 0, "b": 3, "f2": ":Assign=[1]"},144 {"a": 2, "b": 3, "f2": "Dot[0]:Assign=[1]"}145 ],146 "assign":[147 {"v": 0, "giv": "x"},148 {"v": 1, "inf": "a"},149 {"v": 2, "giv": "this"},150 {"v": 3, "inf": "b"}151 ]152 }'153 }154}155bool_const_type: {156 options = {157 features : "FNAMES"158 };159 input: {160 function chunkData() { 161 var x = true;162 }163 }164 expect: {165 '{166 "query":[167 {"a": 0, "b": 1, "f2": "FNDECL"} 168 ],169 "assign":[170 {"v": 0, "giv": "chunkData"},171 {"v": 1, "inf": "x"} 172 ]173 }'174 }175}176handles_toString_call: {177 options = {178 features : "FNAMES"179 };180 input: {181 function chunkData() { 182 var x = true;183 x.toString();184 }185 }186 expect: {187 '{188 "query":[189 {"a": 0, "b": 1, "f2": "FNDECL"}190 ],191 "assign":[192 {"v": 0, "giv": "chunkData"},193 {"v": 1, "inf": "x"} 194 ]195 }'196 }197}198escape_backslash: {199 options = {200 features : "FNAMES"201 };202 input: {203 function chunkData(x) { 204 x.replace(/\s/g, "a");205 }206 }207 expect: {208 '{209 "query":[210 {"a": 0, "b": 1, "f2": "FNPAR"} 211 ],212 "assign":[213 {"v": 0, "giv": "chunkData"},214 {"v": 1, "inf": "x"} 215 ]216 }'217 }218}219func_no_duplicates: {220 options = {221 features : "ASTREL"222 };223 input: {224 function chunkData() { 225 var a = new chunkData();226 a = new chunkData(); 227 }228 }229 expect: {230 '{231 "query":[232 {"a": 0, "b": 1, "f2": ":VarDef[1]New[0]"},233 {"a": 0, "b": 1, "f2": ":Assign=[1]New[0]"}234 ],235 "assign":[236 {"v": 0, "inf": "a"},237 {"v": 1, "giv": "chunkData"}238 ]239 }'240 }241}242func_allow_different_features_duplicates: {243 options = {244 features : "ASTREL"245 };246 input: {247 function chunkData(x) { 248 x.foo(42, 42, 42, 42);249 return 42;250 }251 }252 expect: {253 '{254 "query":[255 {"a": 0, "b": 1, "f2": ":Dot[0]"},256 {"a": 0, "b": 2, "f2": "Dot[0]:Call[1]-Number"},257 {"a": 0, "b": 2, "f2": "Dot[0]:Call[2]-Number"},258 {"a": 0, "b": 2, "f2": "Dot[0]:Call[3]-Number"},259 {"a": 0, "b": 2, "f2": "Dot[0]:Call[4]-Number"}260 ],261 "assign":[262 {"v": 0, "inf": "x"},263 {"v": 1, "giv": "foo"},264 {"v": 2, "giv": "42"}265 ]266 }'267 }268}269method_name_fixed: { 270 input: {271 function chunkData(x) { 272 x.foo();273 bar();274 }275 }276 expect: {277 '{278 "query":[279 {"a": 0, "b": 1, "f2": ":Dot[0]"},280 {"a": 2, "b": 0, "f2": "FNPAR"}281 ],282 "assign":[283 {"v": 0, "inf": "x"},284 {"v": 1, "giv": "foo"},285 {"v": 2, "giv": "chunkData"}286 ]287 }'288 }...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful