Class: GRX::Data::TensorDataset
Overview
================================================================
TensorDataset — Dataset wrapping parallel tensors (e.g. X and Y)
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#tensors ⇒ Object
readonly
Returns the value of attribute tensors.
Instance Method Summary collapse
- #[](index) ⇒ Object
-
#initialize(*tensors) ⇒ TensorDataset
constructor
A new instance of TensorDataset.
Constructor Details
#initialize(*tensors) ⇒ TensorDataset
Returns a new instance of TensorDataset.
24 25 26 27 28 29 30 31 32 |
# File 'lib/grx/data.rb', line 24 def initialize(*tensors) raise ArgumentError, "Must provide at least one tensor" if tensors.empty? first_dim = tensors.first.shape[0] unless tensors.all? { |t| t.shape[0] == first_dim } raise ArgumentError, "All tensors must have the same size in batch dimension (dimension 0)" end @tensors = tensors @size = first_dim end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
22 23 24 |
# File 'lib/grx/data.rb', line 22 def size @size end |
#tensors ⇒ Object (readonly)
Returns the value of attribute tensors.
22 23 24 |
# File 'lib/grx/data.rb', line 22 def tensors @tensors end |