# Path: deeppy/expr/base.py
# class UnaryElementWise(Unary):
#     def setup(self):
#         self.shape = self.x.shape
#         self.array = ca.zeros(self.shape)
#         self.grad_array = ca.zeros(self.shape)


import cudarray as ca
from ..base import UnaryElementWise


class LeakyReLU(UnaryElementWise):
    def __init__(self, a=0.2):
        self.a = a

    def fprop(self):
        ca.minimum(self.x.array, 0, out=self.array)
        self.array *= self.a
        self.array += ca.maximum(self.x.array, 0)

    def bprop(self):
        self.x.grad_array = ca.less(self.x.array, 0) * self.a
        pos = ca.nnet.relu_d(self.x.array)
        self.x.grad_array += pos
        self.x.grad_array *= self.grad_array



# Path: deeppy/expr/base.py
# class UnaryElementWise(Unary):
#     def setup(self):
#         self.shape = self.x.shape
#         self.array = ca.zeros(self.shape)
#         self.grad_array = ca.zeros(self.shape)


# Path: deeppy/expr/nnet/activation.py
import cudarray as ca
from ..base import UnaryElementWise



class LeakyReLU(UnaryElementWise):
    def __init__(self, a=0.2):
        self.a = a

    def fprop(self):
        ca.minimum(self.x.array, 0, out=self.array)
        self.array *= self.a
        self.array += ca.maximum(self.x.array, 0)

    def bprop(self):
        self.x.grad_array = ca.less(self.x.array, 0) * self.a
        pos = ca.nnet.relu_d(self.x.array)
        self.x.grad_array += pos
        self.x.grad_array *= self.grad_array



class ReLU(UnaryElementWise):