Sha256: 07bb1ddced186c0082ffcd1f8b7728c84ef67348b2e276a8b38bccae3f8b7d3c

Contents?: true

Size: 493 Bytes

Versions: 5

Compression:

Stored size: 493 Bytes

Contents

class DNN::Dataset
  def initialize(x_datas, y_datas)
    @x_datas = x_datas
    @y_datas = y_datas
    @num_datas = x_datas.shape[0]
    @indexes = @num_datas.times.to_a.shuffle
  end

  def get_batch(batch_size)
    if @indexes.length < batch_size
      @indexes = @num_datas.times.to_a.shuffle
    end
    batch_indexes = @indexes.shift(batch_size)
    x_batch = @x_datas[batch_indexes, false]
    y_batch = @y_datas[batch_indexes, false]
    [x_batch, y_batch]
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby-dnn-0.9.4 lib/dnn/core/dataset.rb
ruby-dnn-0.9.3 lib/dnn/core/dataset.rb
ruby-dnn-0.9.2 lib/dnn/core/dataset.rb
ruby-dnn-0.9.1 lib/dnn/core/dataset.rb
ruby-dnn-0.9.0 lib/dnn/core/dataset.rb