File tree Expand file tree Collapse file tree 1 file changed +0
-25
lines changed Expand file tree Collapse file tree 1 file changed +0
-25
lines changed Original file line number Diff line number Diff line change 41
41
TorchMultiHeadedAttentionModule ,
42
42
)
43
43
44
-
45
- #######################################################################
46
- # Asserts #
47
- #######################################################################
48
-
49
-
50
- def assert_is_binary (a ):
51
- msg = "Matrix should be one-hot binary"
52
- assert np .array_equal (a , a .astype (bool )), msg
53
- assert np .allclose (np .sum (a , axis = 1 ), np .ones (a .shape [0 ])), msg
54
- return True
55
-
56
-
57
- def assert_is_stochastic (a ):
58
- msg = "Array should be stochastic along the columns"
59
- assert len (a [a < 0 ]) == len (a [a > 1 ]) == 0 , msg
60
- assert np .allclose (np .sum (a , axis = 1 ), np .ones (a .shape [0 ])), msg
61
- return True
62
-
63
-
64
44
#######################################################################
65
45
# Data Generators #
66
46
#######################################################################
@@ -90,11 +70,6 @@ def random_tensor(shape, standardize=False):
90
70
return X
91
71
92
72
93
- def random_binary_tensor (shape , sparsity = 0.5 ):
94
- X = (np .random .rand (* shape ) >= (1 - sparsity )).astype (float )
95
- return X
96
-
97
-
98
73
#######################################################################
99
74
# Debug Formatter #
100
75
#######################################################################
You can’t perform that action at this time.
0 commit comments