Class: Torchrb::DataSet
- Inherits:
-
Object
- Object
- Torchrb::DataSet
- Defined in:
- lib/torchrb/data_set.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#histogram ⇒ Object
readonly
Returns the value of attribute histogram.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #classes ⇒ Object
- #dimensions ⇒ Object
-
#initialize(set, model, collection) ⇒ DataSet
constructor
A new instance of DataSet.
- #is_trainset? ⇒ Boolean
- #load(&progress_callback) ⇒ Object
- #torch ⇒ Object
- #var_name ⇒ Object
Constructor Details
#initialize(set, model, collection) ⇒ DataSet
Returns a new instance of DataSet.
4 5 6 7 8 |
# File 'lib/torchrb/data_set.rb', line 4 def initialize set, model, collection @set = set @model = model @collection = collection end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
3 4 5 |
# File 'lib/torchrb/data_set.rb', line 3 def collection @collection end |
#histogram ⇒ Object (readonly)
Returns the value of attribute histogram.
3 4 5 |
# File 'lib/torchrb/data_set.rb', line 3 def histogram @histogram end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
3 4 5 |
# File 'lib/torchrb/data_set.rb', line 3 def model @model end |
Instance Method Details
#classes ⇒ Object
18 19 20 |
# File 'lib/torchrb/data_set.rb', line 18 def classes model.classes end |
#dimensions ⇒ Object
41 42 43 |
# File 'lib/torchrb/data_set.rb', line 41 def dimensions torch.eval("return (##{var_name}.input):totable()", __FILE__, __LINE__).values.map(&:to_i) end |
#is_trainset? ⇒ Boolean
10 11 12 |
# File 'lib/torchrb/data_set.rb', line 10 def is_trainset? @set == :train_set end |
#load(&progress_callback) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/torchrb/data_set.rb', line 22 def load &progress_callback @progress_callback = progress_callback load_classes if is_trainset? init_variables do_load torch.eval <<-EOF, __FILE__, __LINE__ setmetatable(#{var_name}, {__index = function(t, i) return {t.input[i], t.label[i]} end} ); function #{var_name}:size() return #{var_name}.input:size(1) end EOF self end |
#torch ⇒ Object
45 46 47 |
# File 'lib/torchrb/data_set.rb', line 45 def torch model.torch end |
#var_name ⇒ Object
14 15 16 |
# File 'lib/torchrb/data_set.rb', line 14 def var_name @set.to_s end |