UNPKG

cifar10

Version:

CIFAR-10 data set for nodejs / browser

2 lines 3.1 kB
"use strict";function _classCallCheck(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function t(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(n,e,r){return e&&t(n.prototype,e),r&&t(n,r),n}}();!function(){var t=function(){function t(){_classCallCheck(this,t)}return _createClass(t,null,[{key:"set",value:function(t,n){fetch("/set",{method:"Post",body:JSON.stringify({training:t,test:n})}).then(function(t){return t.json()}).then(function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).dataCount;e&&console.warn("Not enough data ("+e+") for "+t+" training and "+n+" test items. Scaling down.")})}},{key:"reset",value:function(){fetch("/reset")}},{key:"render",value:function(t,n){for(var e=t.input.map(function(t){return 255*t}),r=new Uint8ClampedArray(4096),o=0;o<32;o++)for(var i=0;i<32;i++){var a=4*(32*o+i);r[a]=e[32*o+i],r[a+1]=e[32*o+i+1024],r[a+2]=e[32*o+i+2048],r[a+3]=255}var u=n.createImageData(32,32);u.data.set(r),n.putImageData(u,0,0),n.stroke()}}]),t}();t.categories=["airplane","automobile","bird","cat","deer","dog","frog","horse","ship","truck"],t.categories.forEach(function(n){t[n]={range:function(t,e){return fetch("/range",{method:"Post",body:JSON.stringify({category:n,start:t,end:e})}).then(function(t){return t.json()})},training:{get:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.index,r=t.indexList;return fetch("/category.training.get",{method:"Post",body:JSON.stringify({category:n,index:e,indexList:r,type:"training"})}).then(function(t){return t.json()})},length:function(){return new Promise(function(t,e){fetch("/category.training.length",{method:"Post",body:JSON.stringify({category:n})}).then(function(t){return t.json()}).then(function(n){var e=n.length;return t(e)})})}},test:{get:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.index,r=t.indexList;return fetch("/category.training.get",{method:"Post",body:JSON.stringify({category:n,index:e,indexList:r,type:"test"})}).then(function(t){return t.json()})},length:function(){return new Promise(function(t,e){fetch("/category.test.length",{method:"Post",body:JSON.stringify({category:n})}).then(function(t){return t.json()}).then(function(n){var e=n.length;return t(e)})})}}}}),t.training={get:function(t){return fetch("/training.get",{method:"Post",body:JSON.stringify({count:t})}).then(function(t){return t.json()})},length:function(){return new Promise(function(t,n){fetch("/training.length").then(function(t){return t.json()}).then(function(n){var e=n.length;return t(e)})})}},t.test={get:function(t){return fetch("/test.get",{method:"Post",body:JSON.stringify({count:t})}).then(function(t){return t.json()})},length:function(){return new Promise(function(t,n){fetch("/test.length").then(function(t){return t.json()}).then(function(n){var e=n.length;return t(e)})})}},window.CIFAR10=t}(); //# sourceMappingURL=cifar10-client.min.js.map