# Path: deeppy/base.py
# class ParamMixin(object):
#     @property
#     def params(self):
#         """ List of Parameter objects. """
#         raise NotImplementedError()
# 
#     @params.setter
#     def params(self, params):
#         raise NotImplementedError()


import itertools
import numpy as np
import cudarray as ca
import deeppy as dp
from copy import copy
from deeppy.base import ParamMixin
    assert gradclose(g_true, g_approx, rtol, atol)

    # Check parameter gradients
    if isinstance(layer, ParamMixin):
        def fun(x, p_idx):
            ca.random.seed(seed)
            param_array = layer.params[p_idx].array
            param_array *= 0
            param_array += ca.array(x)
            y = np.array(layer.fprop(ca.array(x0))).astype(np.float_)
            return np.sum(y)

        def fun_grad(x, p_idx):
            param_array = layer.params[p_idx].array
            param_array *= 0
            param_array += ca.array(x)
            out = layer.fprop(ca.array(x0))
            y_grad = ca.ones_like(out, dtype=ca.float_)
            layer.bprop(y_grad)
            param_grad = np.array(layer.params[p_idx].grad())
            return param_grad.astype(np.float_)

        for p_idx, p in enumerate(layer.params):
            x = np.array(layer.params[p_idx].array)
            g_true = fun_grad(x, p_idx)
            g_approx = approx_fprime(x, fun, eps, p_idx)
            assert gradclose(g_true, g_approx, rtol, atol)


def check_params(layer):

# Path: deeppy/base.py
# class ParamMixin(object):
#     @property
#     def params(self):
#         """ List of Parameter objects. """
#         raise NotImplementedError()
# 
#     @params.setter
#     def params(self, params):
#         raise NotImplementedError()


# Path: test/unit/feedforward/test_layers.py
import itertools
import numpy as np
import cudarray as ca
import deeppy as dp
from copy import copy
from deeppy.base import ParamMixin

    assert gradclose(g_true, g_approx, rtol, atol)

    # Check parameter gradients
    if isinstance(layer, ParamMixin):
        def fun(x, p_idx):
            ca.random.seed(seed)
            param_array = layer.params[p_idx].array
            param_array *= 0
            param_array += ca.array(x)
            y = np.array(layer.fprop(ca.array(x0))).astype(np.float_)
            return np.sum(y)

        def fun_grad(x, p_idx):
            param_array = layer.params[p_idx].array
            param_array *= 0
            param_array += ca.array(x)
            out = layer.fprop(ca.array(x0))
            y_grad = ca.ones_like(out, dtype=ca.float_)
            layer.bprop(y_grad)
            param_grad = np.array(layer.params[p_idx].grad())
            return param_grad.astype(np.float_)

        for p_idx, p in enumerate(layer.params):
            x = np.array(layer.params[p_idx].array)
            g_true = fun_grad(x, p_idx)
            g_approx = approx_fprime(x, fun, eps, p_idx)
            assert gradclose(g_true, g_approx, rtol, atol)


def check_params(layer):

    assert isinstance(layer, ParamMixin)