Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Embedding layer looks up embedding from PS (#1435)
* Embedding layer looks up embedding from PS * rename variable * follow comments * minor edits * rename worker_mnist_test.py
- Loading branch information
Showing
4 changed files
with
102 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
import hashlib | ||
|
||
|
||
def string_to_id(name, num): | ||
def string_to_id(name, bucket_num): | ||
h = hashlib.sha256(name.encode("utf-8")) | ||
return int(h.hexdigest(), base=32) % num | ||
return int(h.hexdigest(), base=32) % bucket_num | ||
|
||
|
||
def int_to_id(number, bucket_num): | ||
return number % bucket_num |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters