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

Function random_one_hot_matrix

numpy_ml/utils/testing.py:63–67  ·  view source on GitHub ↗

Create a random one-hot matrix of shape (`n_examples`, `n_classes`)

(n_examples, n_classes)

Source from the content-addressed store, hash-verified

61
62
63def random_one_hot_matrix(n_examples, n_classes):
64 """Create a random one-hot matrix of shape (`n_examples`, `n_classes`)"""
65 X = np.eye(n_classes)
66 X = X[np.random.choice(n_classes, n_examples)]
67 return X
68
69
70def random_stochastic_matrix(n_examples, n_classes):

Callers 3

get_contextMethod · 0.90
test_cross_entropyFunction · 0.90
test_cross_entropy_gradFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected