Ejemplo n.º 1
0
    def __call__(self, *a_inputs, **kwargs):

        # x = a_input.data
        # y = self.forward(x)
        # self.output = BaseVariable(as_array(y))
        # self.output.set_creator(self)
        # self.input = a_input
        a_inputs = [as_variable(x) for x in a_inputs]
        xs = [x.data for x in a_inputs]
        ys = self.forward(*xs)
        if not isinstance(ys, tuple):
            ys = (ys, )
        outputs = [BaseVariable(as_array(y)) for y in ys]

        if Config.enable_backprop:
            self.generation = max([x.generation for x in a_inputs])
            for output in outputs:
                output.set_creator(self)
            self.inputs = a_inputs
            self.outputs = [weakref.ref(output) for output in outputs]
        return outputs if len(outputs) > 1 else outputs[0]
Ejemplo n.º 2
0
def rdiv(x0, x1):
    x1 = as_array(x1)
    return Div()(x1, x0)
Ejemplo n.º 3
0
def add(x0, x1):
    x1 = as_array(x1)
    return Add()(x0, x1)
Ejemplo n.º 4
0
def rsub(x0, x1):
    x1 = as_array(x1)
    return Sub()(x1, x0)