Skip to content

Commit

Permalink
Merge pull request #810 from null-a/disallow-empty-batches
Browse files Browse the repository at this point in the history
Don't allow empty batches, except when data is empty.
  • Loading branch information
stuhlmueller committed Apr 4, 2017
2 parents 505c710 + 24ccf25 commit afeae3e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/inference/elbo.ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,12 @@ module.exports = function(env) {
mapDataFetch: function(data, opts, address) {

var batchSize = opts.batchSize !== undefined ? opts.batchSize : data.length;
if (batchSize < 0 || batchSize > data.length) {
var minBatchSize = _.isEmpty(data) ? 0 : 1;
var maxBatchSize = data.length;

if (!(util.isInteger(batchSize) &&
minBatchSize <= batchSize &&
batchSize <= maxBatchSize)) {
throw new Error('ELBO: Invalid batchSize.');
}

Expand Down

0 comments on commit afeae3e

Please sign in to comment.