Skip to content
This repository has been archived by the owner on Nov 18, 2023. It is now read-only.

Continuous attribute embedding #102

Merged
merged 25 commits into from
Oct 7, 2019

Conversation

jmsfltchr
Copy link
Contributor

What is the goal of this PR?

Enable ingesting numerical attributes with continuous values.

The aim has been to add a continuous numerical attribute to the diagnosis example which adds no additional information. In this case, the model should be able to stably achieve the same performance as without this attribute. Empirically, this has been achieved, perhaps taking longer to converge (about 500 training iterations minimum, compared to a minimum of 250 iterations prior).

Closes #99

What are the changes implemented in this PR?

  • Introduce a continuous numerical attribute into the diagnosis example (severity)
  • Create a ContinuousAttribute model, consisting of an MLP followed by layer normalisation
  • For debugging and monitoring purposes, add histograms at strategic points in the model, plus the relevant code to execute and store these summaries
  • Normalisation of common (type) embeddings for improved stability, such that attribute and type embeddings have similar magnitudes
  • Gradient clipping for a very significant improvement in model convergence and stability
  • Dropout for continuous attribute MLP to combat overfitting
  • Improved the flow of embedder construction

James Fletcher added 24 commits September 19, 2019 16:48
… preventing overfitting.

Reflected in the tensorboard histograms when learning was stagnant/non-existent in the attribute embedders before introducing dropout
… corresponding reporting metrics.

This has made convergence to good performance 4-8 times faster, from 100-200 iterations down to 250 iterations
…d performance. Adding more examples (200), and using a useless attribute always with value zero, the model converges to a good and expected accuracy.

Remove dropout for continuous attributes. Add histograms and better output location for plots
… extra information over the existing type information) works but leads to overfitting
… best combination for stability and minimising overfitting
…lity and speed of convergence of the model
Now that gradient clipping and type embedding normalisation are in place, using dropout as intended in the continuous attribute MLP works very well to counter overfitting whilst keeping good stability. At least, for the first 2000 iterations, possibly trying to overfit subsequent to that
… not specified and therefore summaries should not be written
@jmsfltchr jmsfltchr added this to the 0.2.1 milestone Oct 7, 2019
@jmsfltchr jmsfltchr self-assigned this Oct 7, 2019
step_op = optimizer.minimize(loss_op_tr)
gradients, variables = zip(*optimizer.compute_gradients(loss_op_tr))

for grad, var in zip(gradients, variables):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this for debugging?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and also functional - optimiser.minimize(loss) computes the gradients and applies them. In order to intercept the gradients to do anything with them you have to first compute them and then apply them manually.

Here we do this to:

  1. Visualise the gradients in TensorBoard
  2. Apply gradient clipping as mentioned in the description

@@ -136,3 +124,57 @@ def make_blank_embedder():

_, _, _, _, _, solveds_tr, solveds_ge = tr_info
return ge_graphs, solveds_tr, solveds_ge


def configure_embedders(node_types, attr_embedding_dim, categorical_attributes, continuous_attributes):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bit awkward to read... maybe it can be split into separate file/class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, it's generally awkward and needs more architectural work, including how to expose this configurability to the user. Intending to address this in a separate PR as it's a big task

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added #103

from kglib.kgcn.pipeline.pipeline import configure_embedders


class TestConstructEmbedders(unittest.TestCase):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already being tested separatedly!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean configure_embedders is? Whereabouts?

The name of the test is incorrect though, should be TestConfigureEmbedders

@flyingsilverfin flyingsilverfin self-requested a review October 7, 2019 12:56
@jmsfltchr jmsfltchr merged commit 18af984 into typedb:master Oct 7, 2019
@jmsfltchr jmsfltchr deleted the continuous-attribute-embedding branch October 7, 2019 13:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Embed Continuous Attributes
2 participants