Sha256: 7b140ac7a59c11d3a4ad9ff72a426363df26c21e39014ef486222933ac655a93

Contents?: true

Size: 456 Bytes

Versions: 3

Compression:

Stored size: 456 Bytes

Contents

module TensorStream
  # class that defines a shape for TensorFlow compatibility
  class TensorShape
    attr_accessor :rank, :shape

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

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

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

    def ndims
      shape.size
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tensor_stream-0.1.4 lib/tensor_stream/tensor_shape.rb
tensor_stream-0.1.3 lib/tensor_stream/tensor_shape.rb
tensor_stream-0.1.2 lib/tensor_stream/tensor_shape.rb