Class: DNN::Dataset
- Inherits:
-
Object
- Object
- DNN::Dataset
- Defined in:
- lib/dnn/core/dataset.rb
Instance Method Summary collapse
- #get_batch(batch_size) ⇒ Object
-
#initialize(x_datas, y_datas) ⇒ Dataset
constructor
A new instance of Dataset.
Constructor Details
#initialize(x_datas, y_datas) ⇒ Dataset
Returns a new instance of Dataset.
2 3 4 5 6 7 |
# File 'lib/dnn/core/dataset.rb', line 2 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 |
Instance Method Details
#get_batch(batch_size) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/dnn/core/dataset.rb', line 9 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 |