UNPKG

mlts-experiment-data

Version:

Machine learning experiment data downloader.

39 lines 1.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var path = require("path"); var downloader = require("../utils/downloader"); var Data_1 = require("../Data"); var idx = require("idx-data"); var utils_1 = require("../utils/utils"); var dataRemoteLocation = 'https://rawgit.com/andnp/ml_data/master/gs_cifar10.tar.gz'; function download(location) { if (location === void 0) { location = '.tmp'; } return downloader.download(dataRemoteLocation, location); } exports.download = download; function load(location) { if (location === void 0) { location = '.tmp'; } return tslib_1.__awaiter(this, void 0, void 0, function () { var root, _a, dataX, dataY, _b, x, t, _c, y, ty; return tslib_1.__generator(this, function (_d) { switch (_d.label) { case 0: return [4 /*yield*/, download(location)]; case 1: _d.sent(); root = path.join(location, 'cifar'); return [4 /*yield*/, Promise.all([ idx.loadBits(path.join(root, 'cifar_data.idx')), idx.loadBits(path.join(root, 'cifar_labels.idx')), ])]; case 2: _a = tslib_1.__read.apply(void 0, [_d.sent(), 2]), dataX = _a[0], dataY = _a[1]; _b = tslib_1.__read(utils_1.splitTensor(dataX, 50000), 2), x = _b[0], t = _b[1]; _c = tslib_1.__read(utils_1.splitTensor(dataY, 50000), 2), y = _c[0], ty = _c[1]; return [2 /*return*/, new Data_1.Dataset(x, y, t, ty)]; } }); }); } exports.load = load; //# sourceMappingURL=gray_cifar10.js.map