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
76cdc527
Commit
76cdc527
authored
May 22, 2018
by
Janardhan Pulivarthi
Browse files
resolve 'float' to 'int' conversion, StringIO import, conacat str + byte
parent
8507934f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
4 deletions
+8
-4
research/neural_gpu/data_utils.py
research/neural_gpu/data_utils.py
+2
-2
research/neural_gpu/program_utils.py
research/neural_gpu/program_utils.py
+5
-1
research/neural_gpu/wmt_utils.py
research/neural_gpu/wmt_utils.py
+1
-1
No files found.
research/neural_gpu/data_utils.py
View file @
76cdc527
...
@@ -111,7 +111,7 @@ def init_data(task, length, nbr_cases, nclass):
...
@@ -111,7 +111,7 @@ def init_data(task, length, nbr_cases, nclass):
"""Data initialization."""
"""Data initialization."""
def
rand_pair
(
l
,
task
):
def
rand_pair
(
l
,
task
):
"""Random data pair for a task. Total length should be <= l."""
"""Random data pair for a task. Total length should be <= l."""
k
=
(
l
-
1
)
/
2
k
=
int
(
(
l
-
1
)
/
2
)
base
=
10
base
=
10
if
task
[
0
]
==
"b"
:
base
=
2
if
task
[
0
]
==
"b"
:
base
=
2
if
task
[
0
]
==
"q"
:
base
=
4
if
task
[
0
]
==
"q"
:
base
=
4
...
@@ -135,7 +135,7 @@ def init_data(task, length, nbr_cases, nclass):
...
@@ -135,7 +135,7 @@ def init_data(task, length, nbr_cases, nclass):
def
rand_dup_pair
(
l
):
def
rand_dup_pair
(
l
):
"""Random data pair for duplication task. Total length should be <= l."""
"""Random data pair for duplication task. Total length should be <= l."""
k
=
l
/
2
k
=
int
(
l
/
2
)
x
=
[
np
.
random
.
randint
(
nclass
-
1
)
+
1
for
_
in
xrange
(
k
)]
x
=
[
np
.
random
.
randint
(
nclass
-
1
)
+
1
for
_
in
xrange
(
k
)]
inp
=
x
+
[
0
for
_
in
xrange
(
l
-
k
)]
inp
=
x
+
[
0
for
_
in
xrange
(
l
-
k
)]
res
=
x
+
x
+
[
0
for
_
in
xrange
(
l
-
2
*
k
)]
res
=
x
+
x
+
[
0
for
_
in
xrange
(
l
-
2
*
k
)]
...
...
research/neural_gpu/program_utils.py
View file @
76cdc527
...
@@ -16,10 +16,14 @@
...
@@ -16,10 +16,14 @@
import
contextlib
import
contextlib
import
sys
import
sys
import
StringIO
import
random
import
random
import
os
import
os
try
:
import
StringIO
except
ImportError
:
from
io
import
StringIO
class
ListType
(
object
):
class
ListType
(
object
):
def
__init__
(
self
,
arg
):
def
__init__
(
self
,
arg
):
self
.
arg
=
arg
self
.
arg
=
arg
...
...
research/neural_gpu/wmt_utils.py
View file @
76cdc527
...
@@ -43,7 +43,7 @@ _CHAR_MARKER = "_CHAR_"
...
@@ -43,7 +43,7 @@ _CHAR_MARKER = "_CHAR_"
_CHAR_MARKER_LEN
=
len
(
_CHAR_MARKER
)
_CHAR_MARKER_LEN
=
len
(
_CHAR_MARKER
)
_SPEC_CHARS
=
""
+
chr
(
226
)
+
chr
(
153
)
+
chr
(
128
)
_SPEC_CHARS
=
""
+
chr
(
226
)
+
chr
(
153
)
+
chr
(
128
)
_PUNCTUATION
=
"][.,!?
\"
':;%$#@&*+}{|><=/^~)(_`,0123456789"
+
_SPEC_CHARS
+
"-"
_PUNCTUATION
=
"][.,!?
\"
':;%$#@&*+}{|><=/^~)(_`,0123456789"
+
_SPEC_CHARS
+
"-"
_WORD_SPLIT
=
re
.
compile
(
b
"(["
+
_PUNCTUATION
+
"])"
)
_WORD_SPLIT
=
re
.
compile
(
"(["
+
_PUNCTUATION
+
"])"
)
_OLD_WORD_SPLIT
=
re
.
compile
(
b
"([.,!?
\"
':;)(])"
)
_OLD_WORD_SPLIT
=
re
.
compile
(
b
"([.,!?
\"
':;)(])"
)
_DIGIT_RE
=
re
.
compile
(
br
"\d"
)
_DIGIT_RE
=
re
.
compile
(
br
"\d"
)
...
...
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