{"id":18892995,"url":"https://github.com/dongjunlee/relation-network-tensorflow","last_synced_at":"2026-05-16T11:02:23.967Z","repository":{"id":236588777,"uuid":"119151241","full_name":"DongjunLee/relation-network-tensorflow","owner":"DongjunLee","description":"TensorFlow implementation of 'A simple neural network module for relational reasoning' for bAbi task.","archived":false,"fork":false,"pushed_at":"2018-01-30T11:55:30.000Z","size":435,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-31T06:47:02.285Z","etag":null,"topics":["babi","hb-experiment","qa","relational-reasoning","rn-module","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DongjunLee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-27T09:36:32.000Z","updated_at":"2019-07-14T08:01:51.000Z","dependencies_parsed_at":"2024-05-08T19:15:50.383Z","dependency_job_id":null,"html_url":"https://github.com/DongjunLee/relation-network-tensorflow","commit_stats":null,"previous_names":["dongjunlee/relation-network-tensorflow"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DongjunLee%2Frelation-network-tensorflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DongjunLee%2Frelation-network-tensorflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DongjunLee%2Frelation-network-tensorflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DongjunLee%2Frelation-network-tensorflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DongjunLee","download_url":"https://codeload.github.com/DongjunLee/relation-network-tensorflow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239869222,"owners_count":19710485,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babi","hb-experiment","qa","relational-reasoning","rn-module","tensorflow"],"created_at":"2024-11-08T08:06:58.170Z","updated_at":"2025-10-24T03:54:16.152Z","avatar_url":"https://github.com/DongjunLee.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# Relation Network [![hb-research](https://img.shields.io/badge/hb--research-experiment-green.svg?style=flat\u0026colorA=448C57\u0026colorB=555555)](https://github.com/hb-research)\n\nTensorFlow implementation of [A simple neural network module for relational reasoning](https://arxiv.org/abs/1706.01427) for bAbi task.\n\n![images](images/architecture.png)\n\n- image: A Simple Neural Network Module for Relational Reasoning Slides by Xiadong Gu\n\n## Requirements\n\n- Python 3.6\n- TensorFlow \u003e= 1.4\n- [hb-config](https://github.com/hb-research/hb-config) (Singleton Config)\n- requests\n- tqdm (progress bar)\n- [Slack Incoming Webhook URL](https://my.slack.com/services/new/incoming-webhook/)\n\n\n## Project Structure\n\ninit Project by [hb-base](https://github.com/hb-research/hb-base)\n\n    .\n    ├── config                  # Config files (.yml, .json) using with hb-config\n    ├── data                    # dataset path\n    ├── notebooks               # Prototyping with numpy or tf.interactivesession\n    ├── relation_network        # relation network architecture graphs (from input to logits)\n        ├── __init__.py             # Graph logic\n        ├── encoder.py              # Encoder\n        └── relation.py             # RN Module\n    ├── data_loader.py          # raw_date -\u003e precossed_data -\u003e generate_batch (using Dataset)\n    ├── hook.py                 # training or test hook feature (eg. print_variables)\n    ├── main.py                 # define experiment_fn\n    └── model.py                # define EstimatorSpec\n\nReference : [hb-config](https://github.com/hb-research/hb-config), [Dataset](https://www.tensorflow.org/api_docs/python/tf/data/Dataset#from_generator), [experiments_fn](https://www.tensorflow.org/api_docs/python/tf/contrib/learn/Experiment), [EstimatorSpec](https://www.tensorflow.org/api_docs/python/tf/estimator/EstimatorSpec)\n\n## Todo\n\n- model was trained on the joint version of bAbI (all 20 tasks simultaneously), using the full dataset of 10K examples per task. (paper experiments)\n\n## Config\n\nCan control all **Experimental environment**.\n\nexample: bAbi_task1.yml\n\n```yml\ndata:\n  base_path: 'data/'\n  task_path: 'en-10k/'\n  task_id: 1\n  PAD_ID: 0\n\nmodel:\n  batch_size: 64\n  use_pretrained: false             # (true or false)\n  embed_dim: 32                     # if use_pretrained: only available 50, 100, 200, 300\n  encoder_type: uni                 # uni, bi\n  cell_type: lstm                    # lstm, gru, layer_norm_lstm, nas\n  num_layers: 1\n  num_units: 32\n  dropout: 0.5\n\n  g_units:\n    - 64\n    - 64\n    - 64\n    - 64\n  f_units:\n    - 64\n    - 128\n\n\ntrain:\n  learning_rate: 0.00003\n  optimizer: 'Adam'                # Adagrad, Adam, Ftrl, Momentum, RMSProp, SGD\n\n  train_steps: 200000\n  model_dir: 'logs/bAbi_task1'\n\n  save_checkpoints_steps: 1000\n  check_hook_n_iter: 1000\n  min_eval_frequency: 1\n\n  print_verbose: False\n  debug: False\n\nslack:\n  webhook_url: \"\"                  # after training notify you using slack-webhook\n```\n\n* debug mode : using [tfdbg](https://www.tensorflow.org/programmers_guide/debugger)\n\n\n## Usage\n\nInstall requirements.\n\n```pip install -r requirements.txt```\n\nThen, prepare dataset.\n\n```\nsh scripts/fetch_babi_data.sh\n```\n\nFinally, start train and evaluate model\n```\npython main.py --config bAbi_task1 --mode train_and_evaluate\n```\n\n### Experiments modes\n\n:white_check_mark: : Working  \n:white_medium_small_square: : Not tested yet.\n\n\n- :white_check_mark: `evaluate` : Evaluate on the evaluation data.\n- :white_medium_small_square: `extend_train_hooks` :  Extends the hooks for training.\n- :white_medium_small_square: `reset_export_strategies` : Resets the export strategies with the new_export_strategies.\n- :white_medium_small_square: `run_std_server` : Starts a TensorFlow server and joins the serving thread.\n- :white_medium_small_square: `test` : Tests training, evaluating and exporting the estimator for a single step.\n- :white_check_mark: `train` : Fit the estimator using the training data.\n- :white_check_mark: `train_and_evaluate` : Interleaves training and evaluation.\n\n---\n\n\n### Tensorboar\n\n```tensorboard --logdir logs```\n\n- bAbi_task1\n\n![images](images/tensorboard-bAbi-task1.png)\n\n\n## Reference\n\n- [hb-research/notes - A simple neural network module for relational reasoning](https://github.com/hb-research/notes/blob/master/notes/relational_network.md)\n- [arXiv - A simple neural network module for relational reasoning](https://arxiv.org/abs/1706.01427)\n\n\n## Author\n\n[Dongjun Lee](https://github.com/DongjunLee) (humanbrain.djlee@gmail.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdongjunlee%2Frelation-network-tensorflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdongjunlee%2Frelation-network-tensorflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdongjunlee%2Frelation-network-tensorflow/lists"}