transform

old TransE-like models
git clone https://esimon.eu/repos/transform.git
Log | Files | Refs | README

translations.py (518B)


      1 #!/usr/bin/env python2
      2 
      3 from relations.base import *
      4 
      5 class Translations(Base_relation):
      6     """ Translations class.
      7 
      8     This class has one parameter:
      9     T -- the translations
     10     """
     11     def __init__(self, rng, number, dimension, tag):
     12         """ Initialise the parameter. """
     13         parameters = [ ('T', (dimension,)) ]
     14         super(Translations, self).__init__(rng, number, parameters, tag)
     15 
     16     def apply(self, inputs, t):
     17         """ Apply the given relations to a given input. """
     18         return t + inputs