Skip to content

Commit be3b88d

Browse files
authored
Merge pull request #477 from seiriosPlus/fix_hash
add hash
2 parents 7a855d7 + a875c7b commit be3b88d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

models/rank/dnn/benchmark_reader.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import six
1717
import os
1818
import copy
19+
import xxhash
1920
import paddle.distributed.fleet as fleet
2021
import logging
2122

@@ -47,7 +48,9 @@ def line_process(self, line):
4748
(float(features[idx]) - cont_min_[idx - 1]) /
4849
cont_diff_[idx - 1])
4950
for idx in categorical_range_:
50-
sparse_feature.append([hash(str(idx) + features[idx]) % hash_dim_])
51+
sparse_feature.append([
52+
xxhash.xxh32(str(idx) + features[idx]).intdigest() % hash_dim_
53+
])
5154
label = [int(features[0])]
5255
return [label] + sparse_feature + [dense_feature]
5356

models/rank/wide_deep/benchmark_reader.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import six
1717
import os
1818
import copy
19+
import xxhash
1920
import paddle.distributed.fleet as fleet
2021
import logging
2122

@@ -47,7 +48,9 @@ def line_process(self, line):
4748
(float(features[idx]) - cont_min_[idx - 1]) /
4849
cont_diff_[idx - 1])
4950
for idx in categorical_range_:
50-
sparse_feature.append([hash(str(idx) + features[idx]) % hash_dim_])
51+
sparse_feature.append([
52+
xxhash.xxh32(str(idx) + features[idx]).intdigest() % hash_dim_
53+
])
5154
label = [int(features[0])]
5255
return [label] + sparse_feature + [dense_feature]
5356

0 commit comments

Comments
 (0)