Class: TensorStream::TensorShape
- Inherits:
-
Object
- Object
- TensorStream::TensorShape
- Defined in:
- lib/tensor_stream/tensor_shape.rb
Overview
class that defines a shape for TensorFlow compatibility
Instance Attribute Summary collapse
-
#rank ⇒ Object
Returns the value of attribute rank.
-
#shape ⇒ Object
Returns the value of attribute shape.
Instance Method Summary collapse
- #[](index) ⇒ Object
-
#initialize(shape, rank) ⇒ TensorShape
constructor
A new instance of TensorShape.
- #ndims ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(shape, rank) ⇒ TensorShape
Returns a new instance of TensorShape.
6 7 8 9 |
# File 'lib/tensor_stream/tensor_shape.rb', line 6 def initialize(shape, rank) @shape = shape @rank = rank end |
Instance Attribute Details
#rank ⇒ Object
Returns the value of attribute rank.
4 5 6 |
# File 'lib/tensor_stream/tensor_shape.rb', line 4 def rank @rank end |
#shape ⇒ Object
Returns the value of attribute shape.
4 5 6 |
# File 'lib/tensor_stream/tensor_shape.rb', line 4 def shape @shape end |
Instance Method Details
#[](index) ⇒ Object
18 19 20 |
# File 'lib/tensor_stream/tensor_shape.rb', line 18 def [](index) @shape[index] end |
#ndims ⇒ Object
22 23 24 |
# File 'lib/tensor_stream/tensor_shape.rb', line 22 def ndims shape.size end |
#to_s ⇒ Object
11 12 13 14 15 16 |
# File 'lib/tensor_stream/tensor_shape.rb', line 11 def to_s dimensions = @shape.collect do |r| "Dimension(#{r})" end.join(',') "TensorShape([#{dimensions}])" end |