reflections.py (627B)
1 #!/usr/bin/env python2 2 3 import theano.tensor as T 4 5 from relations.base import * 6 7 class Reflections(Base_relation): 8 """ Reflections class. 9 10 This class has one parameter: 11 H -- the hyperplanes 12 """ 13 def __init__(self, rng, number, dimension, tag): 14 """ Initialise the parameter. """ 15 parameters = [ ('H', (dimension,)) ] 16 super(Reflections, self).__init__(rng, number, parameters, tag) 17 18 def apply(self, inputs, h): 19 """ Apply the given relations to a given input. """ 20 f = (T.sum(inputs*h, axis=1) / T.sum(h*h, axis=1)).dimshuffle(0, 'x') 21 return inputs - 2 * h * f