Class: Chainer::Functions::Array::Assign
Instance Attribute Summary
#inputs, #outputs, #rank
Instance Method Summary
collapse
#apply, #backward_accumulate, #forward_cpu, #get_retained_inputs, #get_retained_outputs, #label, #output_data, #retain_inputs, #retain_outputs, #unchain
Constructor Details
#initialize(shape, dtype, t) ⇒ Assign
48
49
50
51
52
|
# File 'lib/chainer/functions/array/select_item.rb', line 48
def initialize(shape, dtype, t)
@shape = shape
@dtype = dtype
@t = t.data
end
|
Instance Method Details
#backward(indexes, gy) ⇒ Object
66
67
68
|
# File 'lib/chainer/functions/array/select_item.rb', line 66
def backward(indexes, gy)
SelectItem.new.apply([gy[0], @t])
end
|
#forward(inputs) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/chainer/functions/array/select_item.rb', line 54
def forward(inputs)
gx = @dtype.zeros(*@shape)
@t.size.times.each do |i|
gx[i, @t[i]] = inputs[0][i]
end
[gx]
end
|