__author__ = 'victor'
from theano import tensor as T
import utils.theano_ext as T_extra


class Transformer(object):

    def transform(self, param):
        raise NotImplementedError()


class UnitNorm(Transformer):

    def __init__(self, axis=-1):
        self.axis = axis

    def transform(self, param):
        norm = T_extra.norm(param, axis=self.axis, keepdims=True) + 1e-8
        return param / norm
