class Chainer::Functions::Array::Assign
Public Class Methods
new(shape, dtype, t)
click to toggle source
# File lib/chainer/functions/array/select_item.rb, line 48 def initialize(shape, dtype, t) @shape = shape @dtype = dtype @t = t.data end
Public Instance Methods
backward(indexes, gy)
click to toggle source
# File lib/chainer/functions/array/select_item.rb, line 66 def backward(indexes, gy) SelectItem.new.apply([gy[0], @t]) end
forward(inputs)
click to toggle source
# File lib/chainer/functions/array/select_item.rb, line 54 def forward(inputs) gx = @dtype.zeros(*@shape) # TODO: gx[six.moves.range(self.t.size), self.t] = inputs[0] # binding.pry @t.size.times.each do |i| gx[i, @t[i]] = inputs[0][i] end [gx] end