Class: TensorStream::TensorShape

Inherits:
Object
  • Object
show all
Defined in:
lib/tensor_stream/tensor_shape.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shape, rank) ⇒ TensorShape

Returns a new instance of TensorShape.



5
6
7
8
# File 'lib/tensor_stream/tensor_shape.rb', line 5

def initialize(shape, rank)
  @shape = shape
  @rank = rank
end

Instance Attribute Details

#rankObject

Returns the value of attribute rank.



3
4
5
# File 'lib/tensor_stream/tensor_shape.rb', line 3

def rank
  @rank
end

#shapeObject

Returns the value of attribute shape.



3
4
5
# File 'lib/tensor_stream/tensor_shape.rb', line 3

def shape
  @shape
end

Instance Method Details

#[](index) ⇒ Object



17
18
19
# File 'lib/tensor_stream/tensor_shape.rb', line 17

def [](index)
  @shape[index]
end

#ndimsObject



21
22
23
# File 'lib/tensor_stream/tensor_shape.rb', line 21

def ndims
  shape.size
end

#to_sObject



10
11
12
13
14
15
# File 'lib/tensor_stream/tensor_shape.rb', line 10

def to_s
  dimensions = @shape.collect do |r|
    "Dimension(#{r})"
  end.join(',')
  "TensorShape([#{dimensions}])"
end