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
ModelZoo
ResNet50_tensorflow
Commits
a533325c
Commit
a533325c
authored
Dec 08, 2016
by
Xin Pan
Committed by
GitHub
Dec 08, 2016
Browse files
Merge pull request #725 from pranay360/master
Fix for issue #621
parents
821d3da7
f1e8ff7c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
textsum/data.py
textsum/data.py
+5
-0
textsum/seq2seq_attention.py
textsum/seq2seq_attention.py
+4
-4
No files found.
textsum/data.py
View file @
a533325c
...
@@ -56,6 +56,11 @@ class Vocab(object):
...
@@ -56,6 +56,11 @@ class Vocab(object):
if
self
.
_count
>
max_size
:
if
self
.
_count
>
max_size
:
raise
ValueError
(
'Too many words: >%d.'
%
max_size
)
raise
ValueError
(
'Too many words: >%d.'
%
max_size
)
def
CheckVocab
(
self
,
word
):
if
word
not
in
self
.
_word_to_id
:
return
None
return
self
.
_word_to_id
[
word
]
def
WordToId
(
self
,
word
):
def
WordToId
(
self
,
word
):
if
word
not
in
self
.
_word_to_id
:
if
word
not
in
self
.
_word_to_id
:
return
self
.
_word_to_id
[
UNKNOWN_TOKEN
]
return
self
.
_word_to_id
[
UNKNOWN_TOKEN
]
...
...
textsum/seq2seq_attention.py
View file @
a533325c
...
@@ -160,10 +160,10 @@ def _Eval(model, data_batcher, vocab=None):
...
@@ -160,10 +160,10 @@ def _Eval(model, data_batcher, vocab=None):
def
main
(
unused_argv
):
def
main
(
unused_argv
):
vocab
=
data
.
Vocab
(
FLAGS
.
vocab_path
,
1000000
)
vocab
=
data
.
Vocab
(
FLAGS
.
vocab_path
,
1000000
)
# Check for presence of required special tokens.
# Check for presence of required special tokens.
assert
vocab
.
WordToId
(
data
.
PAD_TOKEN
)
>
0
assert
vocab
.
CheckVocab
(
data
.
PAD_TOKEN
)
>
0
assert
vocab
.
WordToId
(
data
.
UNKNOWN_TOKEN
)
>=
0
assert
vocab
.
CheckVocab
(
data
.
UNKNOWN_TOKEN
)
>=
0
assert
vocab
.
WordToId
(
data
.
SENTENCE_START
)
>
0
assert
vocab
.
CheckVocab
(
data
.
SENTENCE_START
)
>
0
assert
vocab
.
WordToId
(
data
.
SENTENCE_END
)
>
0
assert
vocab
.
CheckVocab
(
data
.
SENTENCE_END
)
>
0
batch_size
=
4
batch_size
=
4
if
FLAGS
.
mode
==
'decode'
:
if
FLAGS
.
mode
==
'decode'
:
...
...
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