예제 #1
0
    def apply(self, *variables_list):
        ctx = Autograd.Context()

        input_tensors = [v.data for v in variables_list]
        forward_tensor = self.forward(ctx, *input_tensors)

        output_variable = Variable(forward_tensor)
        output_variable.backward_function = lambda x: self.backward(ctx, x)
        output_variable.backward_variables = [v for v in variables_list]

        return output_variable
예제 #2
0
    def apply(cls, *variables_list):
        new_context = Context()

        input_tensors = [v.data for v in variables_list]
        forward_tensor = cls.forward(new_context, *input_tensors)

        output_variable = Variable(forward_tensor)
        output_variable.backward_function = lambda x: cls.backward(
            new_context, x)
        output_variable.backward_variables = [v for v in variables_list]

        return output_variable