MCPcopy Index your code
hub / github.com/ddbourgin/numpy-ml / test_softplus_grad

Function test_softplus_grad

numpy_ml/tests/test_nn_activations.py:359–374  ·  view source on GitHub ↗
(N=50)

Source from the content-addressed store, hash-verified

357
358
359def test_softplus_grad(N=50):
360 from numpy_ml.neural_nets.activations import SoftPlus
361
362 N = np.inf if N is None else N
363
364 mine = SoftPlus()
365 gold = torch_gradient_generator(F.softplus)
366
367 i = 0
368 while i < N:
369 n_ex = np.random.randint(1, 100)
370 n_dims = np.random.randint(1, 100)
371 z = random_tensor((n_ex, n_dims), standardize=True)
372 assert_almost_equal(mine.grad(z), gold(z))
373 print("PASSED")
374 i += 1
375
376
377if __name__ == "__main__":

Callers

nothing calls this directly

Calls 4

gradMethod · 0.95
SoftPlusClass · 0.90
random_tensorFunction · 0.90
torch_gradient_generatorFunction · 0.70

Tested by

no test coverage detected