"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Dataset = void 0;
const autograd_1 = require("../autograd");
const array_1 = require("../array");
class Dataset {
    constructor(inputs, targets, batchSize) {
        this.inputs = inputs;
        this.targets = targets;
        this.batchSize = batchSize;
    }
    *batches() {
        const n = this.inputs.length;
        for (let i = 0; i < n; i += this.batchSize) {
            const end = Math.min(i + this.batchSize, n);
            const batchX = this.inputs.slice(i, end);
            const batchY = this.targets.slice(i, end);
            // Flatten logic depends on input shape. 
            // Assuming 2D arrays (list of lists)
            const dimX = batchX[0].length;
            const dimY = batchY[0].length;
            const flattenX = batchX.flat();
            const flattenY = batchY.flat();
            const bx = new Float32Array(flattenX);
            const by = new Float32Array(flattenY);
            const tx = new autograd_1.Tensor(new array_1.Array(bx, [batchX.length, dimX]), [batchX.length, dimX], false);
            const ty = new autograd_1.Tensor(new array_1.Array(by, [batchY.length, dimY]), [batchY.length, dimY], false);
            yield { inputs: tx, targets: ty };
        }
    }
}
exports.Dataset = Dataset;
//# sourceMappingURL=dataset.js.map