cifar-10
Version:
use CIFAR-10 in Javascript
2 lines • 13.9 kB
JavaScript
;function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function bufferSplit(e,n){cov_1fj4aexxlh.f[0]++,cov_1fj4aexxlh.s[1]++,(0,_assert2.default)(e.length%n==0);var l=(cov_1fj4aexxlh.s[2]++,e.length/n);return cov_1fj4aexxlh.s[3]++,range(n).map(function(n){return cov_1fj4aexxlh.f[1]++,cov_1fj4aexxlh.s[4]++,e.slice(l*n,l*(n+1))})}function flatten(e){return cov_1fj4aexxlh.f[2]++,cov_1fj4aexxlh.s[5]++,e.reduce(function(e,n){var l=n.X,o=n.y;return cov_1fj4aexxlh.f[3]++,cov_1fj4aexxlh.s[6]++,e.X=e.X.concat(l),cov_1fj4aexxlh.s[7]++,e.y=e.y.concat(o),cov_1fj4aexxlh.s[8]++,e},{X:[],y:[]})}function range(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(cov_1fj4aexxlh.b[0][0]++,e);cov_1fj4aexxlh.f[4]++,cov_1fj4aexxlh.s[9]++,e===n?(cov_1fj4aexxlh.b[1][0]++,cov_1fj4aexxlh.s[10]++,e=0):cov_1fj4aexxlh.b[1][1]++;var l=(cov_1fj4aexxlh.s[11]++,[]);cov_1fj4aexxlh.s[12]++;for(var o=e;o<n;o++)cov_1fj4aexxlh.s[13]++,l.push(o);return cov_1fj4aexxlh.s[14]++,l}function isStream(e){return cov_1fj4aexxlh.f[5]++,cov_1fj4aexxlh.s[15]++,cov_1fj4aexxlh.b[2][0]++,null!==e&&(cov_1fj4aexxlh.b[2][1]++,"object"===(void 0===e?"undefined":(0,_typeof3.default)(e)))&&(cov_1fj4aexxlh.b[2][2]++,"function"==typeof e.pipe)}function createStream(e,n){var l=n.totalSize;if(cov_1fj4aexxlh.f[10]++,cov_1fj4aexxlh.s[26]++,!_fs2.default.existsSync(e))throw cov_1fj4aexxlh.b[3][0]++,cov_1fj4aexxlh.s[27]++,new Error("Data files are not existed. Run '"+__dirname+"/get_datasets.sh'");cov_1fj4aexxlh.b[3][1]++;var o=(cov_1fj4aexxlh.s[28]++,_fs2.default.createReadStream(e,{highWaterMark:l}));return cov_1fj4aexxlh.s[29]++,o}function createPromise(e,n){cov_1fj4aexxlh.f[11]++;var l=(cov_1fj4aexxlh.s[30]++,[]);return cov_1fj4aexxlh.s[31]++,new _promise2.default(function(o,t){function c(e){cov_1fj4aexxlh.f[13]++,cov_1fj4aexxlh.s[32]++,l.push(n.mapper(e))}function a(){cov_1fj4aexxlh.f[14]++;var e=(cov_1fj4aexxlh.s[33]++,l.reduce(function(e,n){var l=n.X,o=n.y;return cov_1fj4aexxlh.f[15]++,cov_1fj4aexxlh.s[34]++,e.X.push(l),cov_1fj4aexxlh.s[35]++,e.y.push(o),cov_1fj4aexxlh.s[36]++,e},{X:[],y:[]}));cov_1fj4aexxlh.s[37]++,o(e),cov_1fj4aexxlh.s[38]++,l=null,cov_1fj4aexxlh.s[39]++,i()}function i(){cov_1fj4aexxlh.f[16]++,cov_1fj4aexxlh.s[40]++,e.removeListener("data",c),cov_1fj4aexxlh.s[41]++,e.removeListener("end",a),cov_1fj4aexxlh.s[42]++,e.removeListener("close",a)}cov_1fj4aexxlh.f[12]++,cov_1fj4aexxlh.s[43]++;try{cov_1fj4aexxlh.s[44]++,e.on("data",c),cov_1fj4aexxlh.s[45]++,e.on("end",a),cov_1fj4aexxlh.s[46]++,e.on("close",a)}catch(e){i(),t(e)}})}var cov_1fj4aexxlh=function(){var e="/Users/kp/workspace/playground/cifar-10-js/src/index.js",n="058f1d751749e53b078643f8aafc9971f3fc4afe",l=new Function("return this")(),o="__coverage__",t={path:"/Users/kp/workspace/playground/cifar-10-js/src/index.js",statementMap:{0:{start:{line:5,column:15},end:{line:5,column:50}},1:{start:{line:9,column:2},end:{line:9,column:38}},2:{start:{line:10,column:19},end:{line:10,column:40}},3:{start:{line:11,column:2},end:{line:11,column:77}},4:{start:{line:11,column:33},end:{line:11,column:75}},5:{start:{line:15,column:2},end:{line:22,column:5}},6:{start:{line:16,column:4},end:{line:16,column:28}},7:{start:{line:17,column:4},end:{line:17,column:28}},8:{start:{line:18,column:4},end:{line:18,column:15}},9:{start:{line:26,column:2},end:{line:26,column:31}},10:{start:{line:26,column:21},end:{line:26,column:31}},11:{start:{line:27,column:17},end:{line:27,column:19}},12:{start:{line:29,column:2},end:{line:30,column:19}},13:{start:{line:30,column:4},end:{line:30,column:19}},14:{start:{line:32,column:2},end:{line:32,column:16}},15:{start:{line:36,column:2},end:{line:38,column:38}},16:{start:{line:42,column:23},end:{line:66,column:1}},17:{start:{line:45,column:4},end:{line:45,column:51}},18:{start:{line:48,column:4},end:{line:48,column:52}},19:{start:{line:48,column:31},end:{line:48,column:50}},20:{start:{line:51,column:4},end:{line:51,column:42}},21:{start:{line:58,column:4},end:{line:58,column:65}},22:{start:{line:61,column:14},end:{line:61,column:22}},23:{start:{line:62,column:14},end:{line:63,column:46}},24:{start:{line:63,column:26},end:{line:63,column:45}},25:{start:{line:64,column:4},end:{line:64,column:20}},26:{start:{line:71,column:2},end:{line:73,column:3}},27:{start:{line:72,column:6},end:{line:72,column:87}},28:{start:{line:75,column:17},end:{line:75,column:73}},29:{start:{line:77,column:2},end:{line:77,column:16}},30:{start:{line:81,column:15},end:{line:81,column:17}},31:{start:{line:83,column:2},end:{line:117,column:5}},32:{start:{line:85,column:6},end:{line:85,column:39}},33:{start:{line:89,column:18},end:{line:96,column:8}},34:{start:{line:90,column:8},end:{line:90,column:22}},35:{start:{line:91,column:8},end:{line:91,column:22}},36:{start:{line:92,column:8},end:{line:92,column:19}},37:{start:{line:97,column:6},end:{line:97,column:19}},38:{start:{line:98,column:6},end:{line:98,column:20}},39:{start:{line:99,column:6},end:{line:99,column:24}},40:{start:{line:103,column:6},end:{line:103,column:46}},41:{start:{line:104,column:6},end:{line:104,column:44}},42:{start:{line:105,column:6},end:{line:105,column:46}},43:{start:{line:108,column:4},end:{line:116,column:5}},44:{start:{line:109,column:6},end:{line:109,column:35}},45:{start:{line:110,column:6},end:{line:110,column:33}},46:{start:{line:111,column:6},end:{line:111,column:35}},47:{start:{line:121,column:13},end:{line:122,column:56}},48:{start:{line:121,column:31},end:{line:121,column:58}},49:{start:{line:122,column:29},end:{line:122,column:55}},50:{start:{line:123,column:2},end:{line:123,column:63}},51:{start:{line:123,column:46},end:{line:123,column:61}},52:{start:{line:127,column:37},end:{line:127,column:79}},53:{start:{line:128,column:35},end:{line:128,column:76}},54:{start:{line:130,column:2},end:{line:135,column:3}}},fnMap:{0:{name:"bufferSplit",decl:{start:{line:8,column:16},end:{line:8,column:27}},loc:{start:{line:8,column:42},end:{line:12,column:1}},line:8},1:{name:"(anonymous_1)",decl:{start:{line:11,column:28},end:{line:11,column:29}},loc:{start:{line:11,column:33},end:{line:11,column:75}},line:11},2:{name:"flatten",decl:{start:{line:14,column:9},end:{line:14,column:16}},loc:{start:{line:14,column:22},end:{line:23,column:1}},line:14},3:{name:"(anonymous_3)",decl:{start:{line:15,column:20},end:{line:15,column:21}},loc:{start:{line:15,column:37},end:{line:19,column:3}},line:15},4:{name:"range",decl:{start:{line:25,column:9},end:{line:25,column:14}},loc:{start:{line:25,column:33},end:{line:33,column:1}},line:25},5:{name:"isStream",decl:{start:{line:35,column:16},end:{line:35,column:24}},loc:{start:{line:35,column:33},end:{line:39,column:1}},line:35},6:{name:"(anonymous_6)",decl:{start:{line:44,column:16},end:{line:44,column:17}},loc:{start:{line:44,column:34},end:{line:46,column:3}},line:44},7:{name:"(anonymous_7)",decl:{start:{line:48,column:26},end:{line:48,column:27}},loc:{start:{line:48,column:31},end:{line:48,column:50}},line:48},8:{name:"(anonymous_8)",decl:{start:{line:60,column:10},end:{line:60,column:11}},loc:{start:{line:60,column:27},end:{line:65,column:3}},line:60},9:{name:"(anonymous_9)",decl:{start:{line:63,column:19},end:{line:63,column:20}},loc:{start:{line:63,column:26},end:{line:63,column:45}},line:63},10:{name:"createStream",decl:{start:{line:70,column:16},end:{line:70,column:28}},loc:{start:{line:70,column:51},end:{line:78,column:1}},line:70},11:{name:"createPromise",decl:{start:{line:80,column:16},end:{line:80,column:29}},loc:{start:{line:80,column:46},end:{line:118,column:1}},line:80},12:{name:"(anonymous_12)",decl:{start:{line:83,column:21},end:{line:83,column:22}},loc:{start:{line:83,column:42},end:{line:117,column:3}},line:83},13:{name:"converter",decl:{start:{line:84,column:13},end:{line:84,column:22}},loc:{start:{line:84,column:29},end:{line:86,column:5}},line:84},14:{name:"resolver",decl:{start:{line:88,column:13},end:{line:88,column:21}},loc:{start:{line:88,column:24},end:{line:100,column:5}},line:88},15:{name:"(anonymous_15)",decl:{start:{line:89,column:32},end:{line:89,column:33}},loc:{start:{line:89,column:49},end:{line:93,column:7}},line:89},16:{name:"removeListeners",decl:{start:{line:102,column:13},end:{line:102,column:28}},loc:{start:{line:102,column:31},end:{line:106,column:5}},line:102},17:{name:"combine",decl:{start:{line:120,column:22},end:{line:120,column:29}},loc:{start:{line:120,column:46},end:{line:124,column:1}},line:120},18:{name:"(anonymous_18)",decl:{start:{line:121,column:23},end:{line:121,column:24}},loc:{start:{line:121,column:31},end:{line:121,column:58}},line:121},19:{name:"(anonymous_19)",decl:{start:{line:122,column:23},end:{line:122,column:24}},loc:{start:{line:122,column:29},end:{line:122,column:55}},line:122},20:{name:"(anonymous_20)",decl:{start:{line:123,column:36},end:{line:123,column:37}},loc:{start:{line:123,column:46},end:{line:123,column:61}},line:123},21:{name:"load",decl:{start:{line:126,column:22},end:{line:126,column:26}},loc:{start:{line:126,column:44},end:{line:136,column:1}},line:126}},branchMap:{0:{loc:{start:{line:25,column:22},end:{line:25,column:31}},type:"default-arg",locations:[{start:{line:25,column:26},end:{line:25,column:31}}],line:25},1:{loc:{start:{line:26,column:2},end:{line:26,column:31}},type:"if",locations:[{start:{line:26,column:2},end:{line:26,column:31}},{start:{line:26,column:2},end:{line:26,column:31}}],line:26},2:{loc:{start:{line:36,column:9},end:{line:38,column:37}},type:"binary-expr",locations:[{start:{line:36,column:9},end:{line:36,column:24}},{start:{line:37,column:4},end:{line:37,column:30}},{start:{line:38,column:4},end:{line:38,column:37}}],line:36},3:{loc:{start:{line:71,column:2},end:{line:73,column:3}},type:"if",locations:[{start:{line:71,column:2},end:{line:73,column:3}},{start:{line:71,column:2},end:{line:73,column:3}}],line:71},4:{loc:{start:{line:126,column:27},end:{line:126,column:42}},type:"default-arg",locations:[{start:{line:126,column:35},end:{line:126,column:42}}],line:126}},s:{0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0},f:{0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0},b:{0:[0],1:[0,0],2:[0,0,0],3:[0,0],4:[0]},_coverageSchema:"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c"},c=l[o]||(l[o]={});return c[e]&&c[e].hash===n?c[e]:(t.hash=n,c[e]=t)}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.load=exports.combine=exports.cifar10=void 0;var _regenerator=require("babel-runtime/regenerator"),_regenerator2=_interopRequireDefault(_regenerator),_asyncToGenerator2=require("babel-runtime/helpers/asyncToGenerator"),_asyncToGenerator3=_interopRequireDefault(_asyncToGenerator2),_promise=require("babel-runtime/core-js/promise"),_promise2=_interopRequireDefault(_promise),_typeof2=require("babel-runtime/helpers/typeof"),_typeof3=_interopRequireDefault(_typeof2),combine=exports.combine=function(){var e=(0,_asyncToGenerator3.default)(_regenerator2.default.mark(function e(n,l){var o;return _regenerator2.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return cov_1fj4aexxlh.f[17]++,cov_1fj4aexxlh.s[47]++,o=n.map(function(e){return cov_1fj4aexxlh.f[18]++,cov_1fj4aexxlh.s[48]++,createStream(e,l)}).map(function(e){return cov_1fj4aexxlh.f[19]++,cov_1fj4aexxlh.s[49]++,createPromise(e,l)}),cov_1fj4aexxlh.s[50]++,e.next=5,_promise2.default.all(o).then(function(e){return cov_1fj4aexxlh.f[20]++,cov_1fj4aexxlh.s[51]++,flatten(e)});case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}},e,this)}));return function(n,l){return e.apply(this,arguments)}}(),load=exports.load=function(){var e=(0,_asyncToGenerator3.default)(_regenerator2.default.mark(function e(){var n,l,o,t,c,a,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:(cov_1fj4aexxlh.b[4][0]++,cifar10);return _regenerator2.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return cov_1fj4aexxlh.f[21]++,cov_1fj4aexxlh.s[52]++,e.next=4,combine(i.trainFiles,i);case 4:return n=e.sent,l=n.X,o=n.y,cov_1fj4aexxlh.s[53]++,e.next=10,combine(i.testFiles,i);case 10:return t=e.sent,c=t.X,a=t.y,cov_1fj4aexxlh.s[54]++,e.abrupt("return",{X_train:l,y_train:o,X_test:c,y_test:a});case 15:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}();exports.bufferSplit=bufferSplit,exports.isStream=isStream,exports.createStream=createStream,exports.createPromise=createPromise;var _fs=require("fs"),_fs2=_interopRequireDefault(_fs),_path=require("path"),_path2=_interopRequireDefault(_path),_assert=require("assert"),_assert2=_interopRequireDefault(_assert),appDir=(cov_1fj4aexxlh.s[0]++,_path2.default.dirname(require.main.filename)),cifar10=exports.cifar10=(cov_1fj4aexxlh.s[16]++,{dir:_path2.default.join(appDir,"cifar-10-batches-bin"),getFileName:function(e){return cov_1fj4aexxlh.f[6]++,cov_1fj4aexxlh.s[17]++,this.dir+"/data_batch_"+e+".bin"},get trainFiles(){var e=this;return cov_1fj4aexxlh.s[18]++,range(1,6).map(function(n){return cov_1fj4aexxlh.f[7]++,cov_1fj4aexxlh.s[19]++,e.getFileName(n)})},get testFiles(){return cov_1fj4aexxlh.s[20]++,[this.dir+"/test_batch.bin"]},cols:32,rows:32,channel:3,valueSize:1,get totalSize(){return cov_1fj4aexxlh.s[21]++,this.valueSize+this.channel*this.cols*this.rows},mapper:function(e){cov_1fj4aexxlh.f[8]++;var n=(cov_1fj4aexxlh.s[22]++,e[0]),l=(cov_1fj4aexxlh.s[23]++,bufferSplit(e.slice(this.valueSize),this.channel).map(function(e){return cov_1fj4aexxlh.f[9]++,cov_1fj4aexxlh.s[24]++,new Uint8Array(e)}));return cov_1fj4aexxlh.s[25]++,{X:l,y:n}}});exports.default={createStream:createStream,createPromise:createPromise,combine:combine,load:load};
//# sourceMappingURL=sourceMap.map