We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e904f87 commit 4058954Copy full SHA for 4058954
1 file changed
applications/FLASK/Transformer/datasets/pretokenize/data_utils.py
@@ -0,0 +1,9 @@
1
+import numpy as np
2
+
3
4
+def random_zero_array(arr, p, mask_token):
5
+ """
6
+ Randomly zero out elements of an array with probability p
7
8
+ mask = np.random.choice([0, 1], size=arr.shape, p=[p, 1 - p])
9
+ return arr * mask + mask_token * (1 - mask)
0 commit comments