File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 2
2
import numpy as np
3
3
4
4
5
+ #######################################################################
6
+ # Assertions #
7
+ #######################################################################
8
+
9
+
5
10
def is_symmetric (X ):
6
11
return np .allclose (X , X .T )
7
12
@@ -72,3 +77,36 @@ def random_tensor(shape, standardize=False):
72
77
73
78
def random_binary_tensor (shape , sparsity = 0.5 ):
74
79
return (np .random .rand (* shape ) >= (1 - sparsity )).astype (float )
80
+
81
+
82
+ def random_paragraph (n_words , vocab = None ):
83
+ if vocab is None :
84
+ vocab = [
85
+ "at" ,
86
+ "stet" ,
87
+ "accusam" ,
88
+ "aliquyam" ,
89
+ "clita" ,
90
+ "lorem" ,
91
+ "ipsum" ,
92
+ "dolor" ,
93
+ "dolore" ,
94
+ "dolores" ,
95
+ "sit" ,
96
+ "amet" ,
97
+ "consetetur" ,
98
+ "sadipscing" ,
99
+ "elitr" ,
100
+ "sed" ,
101
+ "diam" ,
102
+ "nonumy" ,
103
+ "eirmod" ,
104
+ "duo" ,
105
+ "ea" ,
106
+ "eos" ,
107
+ "erat" ,
108
+ "est" ,
109
+ "et" ,
110
+ "gubergren" ,
111
+ ]
112
+ return [np .random .choice (vocab ) for _ in range (n_words )]
Original file line number Diff line number Diff line change 1
1
import numpy as np
2
2
3
3
import scipy
4
+
4
5
from sklearn .neighbors import BallTree as sk_BallTree
5
6
from sklearn .metrics .pairwise import rbf_kernel as sk_rbf
6
7
from sklearn .metrics .pairwise import linear_kernel as sk_linear
7
8
from sklearn .metrics .pairwise import polynomial_kernel as sk_poly
8
9
10
+
9
11
from distance_metrics import euclidean
10
12
from kernels import LinearKernel , PolynomialKernel , RBFKernel
11
13
from data_structures import BallTree
You can’t perform that action at this time.
0 commit comments