Skip to content

Commit 10a7ec5

Browse files
committed
reader
1 parent 8db1444 commit 10a7ec5

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

models/recall/word2vec/word2vec_reader.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import io
1818
import six
1919
import time
20-
import paddle
20+
import random
2121
from paddle.io import IterableDataset
2222

2323

@@ -105,13 +105,16 @@ def __iter__(self):
105105
np.array([int(target_id)]).astype('int64'))
106106
output.append(
107107
np.array([int(context_id)]).astype('int64'))
108-
np.random.seed(12345)
109-
tmp = np.random.sample(self.neg_num)
110-
np.random.seed(12345)
111-
neg_array = self.cs.searchsorted(tmp)
108+
112109
tmp = []
110+
random.seed(12345)
111+
for i in range(self.neg_num):
112+
tmp.append(random.random())
113+
#tmp = np.array([0.92961609, 0.31637555, 0.18391881, 0.20456028, 0.56772503])
114+
neg_array = self.cs.searchsorted(tmp)
115+
#tmp = []
113116
output.append(
114-
np.array([int(str(i))
117+
np.array([int(i)
115118
for i in neg_array]).astype('int64'))
116119
yield output
117120

0 commit comments

Comments
 (0)