class Chainer::FunctionAdapter
Attributes
function[RW]
weak_function[RW]
Public Class Methods
new(function)
click to toggle source
Calls superclass method
Chainer::FunctionNode::new
# File lib/chainer/function.rb, line 101 def initialize(function) super() @weak_function = WeakRef.new(function) function.owned_node = self end
Public Instance Methods
backward(target_input_indexes, grad_outputs)
click to toggle source
# File lib/chainer/function.rb, line 124 def backward(target_input_indexes, grad_outputs) in_data = @inputs.map { |input| input.data } grad_out_data = grad_outputs.map { |grad| grad.nil? ? nil : grad.data } gxs = @function.backward(in_data, grad_out_data) ret = [] target_input_indexes.each do |i| if gxs[i].nil? g = nil else g = Chainer::Variable.new(gxs[i]) g.node.old_style_grad_generator = @function.label end ret << g end ret end
forward(inputs)
click to toggle source
# File lib/chainer/function.rb, line 119 def forward(inputs) retain_inputs(inputs.size.times.to_a) @function.forward(inputs) end
label()
click to toggle source
# File lib/chainer/function.rb, line 115 def label @function.label end