Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
3745583b
Commit
3745583b
authored
Jun 03, 2019
by
Mohit Anand
Committed by
xuehui
Jun 03, 2019
Browse files
Modified function get_id to iterate over dictionary only once. (#1140)
parent
5c31530e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
6 deletions
+2
-6
examples/trials/ga_squad/trial.py
examples/trials/ga_squad/trial.py
+1
-3
examples/trials/weight_sharing/ga_squad/data.py
examples/trials/weight_sharing/ga_squad/data.py
+1
-3
No files found.
examples/trials/ga_squad/trial.py
View file @
3745583b
...
...
@@ -79,9 +79,7 @@ def get_id(word_dict, word):
'''
Return word id.
'''
if
word
in
word_dict
.
keys
():
return
word_dict
[
word
]
return
word_dict
[
'<unk>'
]
return
word_dict
.
get
(
word
,
word_dict
[
'<unk>'
])
def
load_embedding
(
path
):
...
...
examples/trials/weight_sharing/ga_squad/data.py
View file @
3745583b
...
...
@@ -241,9 +241,7 @@ def get_id(word_dict, word):
'''
Given word, return word id.
'''
if
word
in
word_dict
.
keys
():
return
word_dict
[
word
]
return
word_dict
[
'<unk>'
]
return
word_dict
.
get
(
word
,
word_dict
[
'<unk>'
])
def
get_buckets
(
min_length
,
max_length
,
bucket_count
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment