MCPcopy
hub / github.com/ddbourgin/numpy-ml / test_softmax_activation

Function test_softmax_activation

numpy_ml/tests/test_nn.py:442–458  ·  view source on GitHub ↗
(N=15)

Source from the content-addressed store, hash-verified

440
441
442def test_softmax_activation(N=15):
443 from numpy_ml.neural_nets.layers import Softmax
444
445 np.random.seed(12345)
446
447 N = np.inf if N is None else N
448
449 mine = Softmax()
450 gold = lambda z: F.softmax(torch.FloatTensor(z), dim=1).numpy()
451
452 i = 0
453 while i < N:
454 n_dims = np.random.randint(1, 100)
455 z = random_stochastic_matrix(1, n_dims)
456 assert_almost_equal(mine.forward(z), gold(z))
457 print("PASSED")
458 i += 1
459
460
461def test_relu_activation(N=15):

Callers

nothing calls this directly

Calls 3

forwardMethod · 0.95
SoftmaxClass · 0.90
random_stochastic_matrixFunction · 0.90

Tested by

no test coverage detected