Skip to content

Commit

Permalink
Cleaned-up version of the Neural GPU code (runs outside of google3).
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasz Kaiser committed Jan 21, 2016
1 parent d84df16 commit 90d6e3b
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 140 deletions.
6 changes: 6 additions & 0 deletions neural_gpu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
Code for the Neural GPU model as described
in [[http://arxiv.org/abs/1511.08228]].

Requirements:
* TensorFlow (see tensorflow.org for how to install)
* Matplotlib for Python (sudo apt-get install python-matplotlib)

Run: python neural_gpu_trainer.py --task=rev

Maintained by Lukasz Kaiser (lukaszkaiser)
35 changes: 16 additions & 19 deletions neural_gpu/data_utils.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
# Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#==============================================================================

"""Convolutional Gated Recurrent Networks for Algorithm Learning."""

import math
import random
import sys
import time

import google3

import numpy as np
import tensorflow as tf

from google3.third_party.tensorflow.python.platform import gfile
from tensorflow.python.platform import gfile

FLAGS = tf.app.flags.FLAGS

Expand Down Expand Up @@ -162,6 +144,21 @@ def spec(inp):
test_set[task][l].append([inp, target])


def to_symbol(i):
"""Covert ids to text."""
if i == 0: return ""
if i == 11: return "+"
if i == 12: return "*"
return str(i-1)


def to_id(s):
"""Covert text to ids."""
if s == "+": return 11
if s == "*": return 12
return int(s) + 1


def get_batch(max_length, batch_size, do_train, task, offset=None, preset=None):
"""Get a batch of data, training or testing."""
inputs = []
Expand Down
20 changes: 1 addition & 19 deletions neural_gpu/neural_gpu.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,10 @@
# Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#==============================================================================

"""The Neural GPU Model."""

import time

import google3

import tensorflow as tf

from google3.experimental.users.lukaszkaiser.neural_gpu import data_utils
import data_utils


def conv_linear(args, kw, kh, nin, nout, do_bias, bias_start, prefix):
Expand Down
Loading

0 comments on commit 90d6e3b

Please sign in to comment.