Giter VIP home page Giter VIP logo

neural-seq2grid-module's Introduction

Neural Seq2grid Module

Official implementation of "Neural Sequence-to-grid Module for Learning Symbolic Rules" (AAAI 2021) by Segwang Kim, Hyoungwook Nam, Joonyoung Kim, and Kyomin Jung.

This repository contains codes to build a network that follows the sequence-input grid-output structure, such as S2G-CNN, consisting of the seq2grid module and the grid decoder. Our seq2grid module automatically segments and aligns the input sequence into a grid. In particular, we implement the module using differentiable nested lists, enabling end-to-end training of the model without supervision for the alignment. Experiments with number sequence prediction problems, computer program evaluation problems, algebraic word problems, and the bAbI QA tasks are possible.

Run example_arithmetic_and_algorithmic.sh: Generate the algebraic word problem, train an S2G-ACNN, and decode results from the S2G-ACNN.

Our implementation is based on the tensor2tensor library.

Requirements

tensorflow==1.13.1 (tested on cuda-10.0, cudnn-7.6)
python==3.6
tensor2tensor==1.13.1
tensorflow-probability==0.6.0
mesh-tensorflow==0.0.5
nltk
pandas
mathematics_dataset (https://github.com/deepmind/mathematics_dataset)

The following commands are for generating data, training a model, and evaluating the model.

Refer to example_arithmetic_and_algorithmic.sh or example_babi.sh for variable settings, e.g., PROBLEM, HPARAMS_SET, MODEL and so on.

Generate Data and Train a Model

CUDA_VISIBLE_DEVICES=${GPU_NUM}, t2t-trainer 
            --generate_data \
            --data_dir=${DATA_DIR} \
            --tmp_dir=${TMP_DIR} \
            --output_dir=${MODEL_DIR} \
            --t2t_usr_dir=${T2T_USR_DIR} \
            --problem=${PROBLEM} \
            --model=${MODEL} \
            --hparams_set=${HPARAMS_SET} \
            --train_steps=${TRAIN_STEPS} 

Decode

DECODING_PY="experiments/autoregressive_decode.py"
CUDA_VISIBLE_DEVICES=${GPU_NUM} python ${DECODING_PY} 
                      --data_dir=${DATA_DIR} \
                      --problem=${PROBLEM} \
                      --model=${MODEL} \
                      --hparams_set=${HPARAMS_SET} \
                      --t2t_usr_dir=${T2T_USR_DIR} \
                      --model_dir=${MODEL_DIR} \
                      --test_shard=${TEST_SHARD} \
                      --global_steps=${TRAIN_STEPS} 
                      --decode_to_file=${DECODE_TO_FILE} 

neural-seq2grid-module's People

Contributors

segwangkim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.