homotheties.py (631B)
1 #!/usr/bin/env python2 2 3 import theano.tensor as T 4 from relations.base import * 5 6 class Homotheties(Base_relation): 7 """ Homotheties class. 8 9 This class has two parameters: 10 P -- the homothetic centers 11 S -- the scaling factor 12 """ 13 def __init__(self, rng, number, dimension, tag): 14 """ Initialise the parameter. """ 15 parameters = [ ('P', (dimension,)), ('S', (1,)) ] 16 super(Homotheties, self).__init__(rng, number, parameters, tag) 17 18 def apply(self, inputs, p, s): 19 """ Apply the given relations to a given input. """ 20 s = T.addbroadcast(s, 1) 21 return p + (inputs-p)*s