def gradientCheck(module, tolerance=0.0001, dataset=None):
    if module.paramdim == 0:
        print('Module has no parameters')
        return True
    if dataset:
        d = dataset
    else:
        d = buildAppropriateDataset(module)
    b = BackpropTrainer(module)
    res = b._checkGradient(d, True)
    # compute average precision on every parameter
    precision = zeros(module.paramdim)
    for seqres in res:
        for i, p in enumerate(seqres):
            if p[0] == 0 and p[1] == 0:
                precision[i] = 0
            else:
                precision[i] += abs((p[0] + p[1]) / (p[0] - p[1]))
    precision /= len(res)
    if max(precision) < tolerance:
        print('Perfect gradient')
        return True
    else:
        print(('Incorrect gradient', precision))
        if isinstance(module, Network):
            index = 0
            for m in module._containerIterator():
                if max(precision[index:index + m.paramdim]) > tolerance:
                    print(('Incorrect module:', m, res[-1][index:index + m.paramdim]))
                index += m.paramdim
        else:
            print(res)
        return False
Environ: Request.json property.
dataset/ETHPy150Open pybrain/pybrain/pybrain/tests/helpers.py/gradientCheck--crossover with--dataset/ETHPy150Open zeaphoo/cocopot/tests/test_request.py/test_json_valid