Sha256: 49c69131b318233e6cc0b8fffc52798f11eca2774edc5aaadc96a7eac0c4c0c8

Contents?: true

Size: 780 Bytes

Versions: 1

Compression:

Stored size: 780 Bytes

Contents

module DNN
  class Tensor
    attr_reader :data
    attr_accessor :link

    def self.convert(inputs)
      if inputs.is_a?(Array)
        inputs.map { |input| Tensor.new(input) }
      else
        Tensor.new(inputs)
      end
    end

    def initialize(data, link = nil)
      @data = data
      @link = link
    end

    def >>(layer)
      layer.(self)
    end

    def shape
      @data.shape
    end

    def +@
      self
    end

    def -@
      Neg.(self)
    end

    def +(other)
      Layers::Add.(self, other)
    end

    def -(other)
      Layers::Sub.(self, other)
    end

    def *(other)
      Layers::Mul.(self, other)
    end

    def /(other)
      Layers::Div.(self, other)
    end

    def **(index)
      Layers::Pow.new(index).(self)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-dnn-1.1.0 lib/dnn/core/tensor.rb