Sha256: 11fcb74ab27e3089f80f779c8b1d83874f77cf2f173ed8dc138f61df5c170c9b

Contents?: true

Size: 620 Bytes

Versions: 8

Compression:

Stored size: 620 Bytes

Contents

module DNN
  class Link
    attr_accessor :prev
    attr_accessor :layer

    def initialize(prev = nil, layer = nil)
      @prev = prev
      @layer = layer
    end

    def backward(dy)
      dy = @layer.backward(dy)
      @prev&.backward(dy)
    end
  end

  class TwoInputLink
    attr_accessor :prev1
    attr_accessor :prev2
    attr_accessor :layer

    def initialize(prev1 = nil, prev2 = nil, layer = nil)
      @prev1 = prev1
      @prev2 = prev2
      @layer = layer
    end

    def backward(dy)
      dy1, dy2 = *@layer.backward(dy)
      @prev1&.backward(dy1)
      @prev2&.backward(dy2)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ruby-dnn-0.15.3 lib/dnn/core/link.rb
ruby-dnn-0.15.2 lib/dnn/core/link.rb
ruby-dnn-0.15.1 lib/dnn/core/link.rb
ruby-dnn-0.15.0 lib/dnn/core/link.rb
ruby-dnn-0.14.3 lib/dnn/core/link.rb
ruby-dnn-0.14.2 lib/dnn/core/link.rb
ruby-dnn-0.14.1 lib/dnn/core/link.rb
ruby-dnn-0.14.0 lib/dnn/core/link.rb