kimhc6028 / relational-networks
- суббота, 10 июня 2017 г. в 03:11:46
Python
Pytorch implementation of "A simple neural network module for relational reasoning" (Relational Networks)
Pytorch implementation of Relational Networks - A simple neural network module for relational reasoning
Implemented & tested on Sort-of-CLEVR task.
Sort-of-CLEVR is simplified version of CLEVR.This is composed of 10000 images and 20 questions (10 relational questions and 10 non-relational questions) per each image. 6 colors (red, green, blue, orange, gray, yellow) are assigned to randomly chosen shape (square or circle), and placed in a image.
Non-relational questions are composed of 3 subtypes:
Theses questions are "non-relational" because the agent only need to focus on certain object.
Relational questions are composed of 3 subtypes:
These questions are "relational" because the agent has to consider the relations between objects.
Questions are encoded into a vector of size of 11 : 6 for one-hot vector for certain color among 6 colors, 2 for one-hot vector of relational/non-relational questions. 3 for one-hot vector of 3 subtypes.
I.e., with the sample image shown, we can generate non-relational questions like:
And relational questions:
$ ./run.sh
or
$ python sort_of_clevr_generator.py
to generate sort-of-clevr dataset and
$ python main.py
to train.
Relational Networks (3rd epoch) | CNN + MLP (without RN, 10th epoch) | |
---|---|---|
Non-relational question | 57% | 58% |
Relational question | 70% | 43% |
Relational networks shows far better results in relational questions, as the original paper argues.
Still this model shows low accuracy overall - I guess it could be the problem of either the architecture of the model, or difference between my dataset and the author's dataset. Please wait for further improvement! (and your pull requests are always welcome!)