Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions research/neural_gpu/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def init_data(task, length, nbr_cases, nclass):
"""Data initialization."""
def rand_pair(l, task):
"""Random data pair for a task. Total length should be <= l."""
k = (l-1)/2
k = int((l-1)/2)
base = 10
if task[0] == "b": base = 2
if task[0] == "q": base = 4
Expand All @@ -135,7 +135,7 @@ def rand_pair(l, task):

def rand_dup_pair(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)]
inp = x + [0 for _ in xrange(l - k)]
res = x + x + [0 for _ in xrange(l - 2*k)]
Expand Down
6 changes: 5 additions & 1 deletion research/neural_gpu/program_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@

import contextlib
import sys
import StringIO
import random
import os

try:
import StringIO
except ImportError:
from io import StringIO

class ListType(object):
def __init__(self, arg):
self.arg = arg
Expand Down
2 changes: 1 addition & 1 deletion research/neural_gpu/wmt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
_CHAR_MARKER_LEN = len(_CHAR_MARKER)
_SPEC_CHARS = "" + chr(226) + chr(153) + chr(128)
_PUNCTUATION = "][.,!?\"':;%$#@&*+}{|><=/^~)(_`,0123456789" + _SPEC_CHARS + "-"
_WORD_SPLIT = re.compile(b"([" + _PUNCTUATION + "])")
_WORD_SPLIT = re.compile("([" + _PUNCTUATION + "])")
_OLD_WORD_SPLIT = re.compile(b"([.,!?\"':;)(])")
_DIGIT_RE = re.compile(br"\d")

Expand Down