Class: TensorStream::TensorShape

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

Overview

class that defines a shape for TensorFlow compatibility

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#rankObject

Returns the value of attribute rank.



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

def rank
  @rank
end

#shapeObject

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

#ndimsObject



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

def ndims
  shape.size
end

#to_sObject



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