@@ -0,0 +1,2138 @@
+#!/usr/bin/env python2%0A# -*- coding: utf-8 -*-%0A# File: pool.py%0A# Date: Thu Sep 18 01:55:04 2014 -0700%0A# Author: Xi-Jin Zhang %3Czhangxijin91@gmail.com%3E%0A%0Aimport __builtin__%0Aimport theano%0Aimport theano.tensor as T%0Aimport theano.printing as PP%0Aimport numpy as np%0A%0Afrom common import Layer%0A%0Aclass SimpleNormalizingLayer(Layer):%0A    NAME = 'sn'%0A%0A    def __init__(self, input_train, input_test,%0A                 image_shape, provide_stdvar, provide_mean):%0A        super(SimpleNormalizingLayer, self).__init__(None, input_train, input_test)%0A        self.image_shape = image_shape%0A        self.provide_stdvar = provide_stdvar%0A        self.provide_mean = provide_mean%0A        if self.provide_stdvar is not None:%0A            def get_stdvar(intput):%0A                return self.provide_stdvar%0A        else:%0A            def get_stdvar(input):%0A                return T.std(input)%0A        if self.provide_mean is not None:%0A            def get_mean(intput):%0A                return self.provide_mean%0A        else:%0A            def get_mean(input):%0A                return T.mean(input)%0A            %0A        def gen_normalize(input):%0A            stdvar = get_stdvar(input)%0A            ret = T.zeros_like(input)%0A            for i in range(image_shape%5B0%5D):%0A                rt%5Bi,:%5D = (input%5Bi,:%5D-get_mean(input%5Bi,:%5D))/stdvar%0A            return ret    %0A%0A        self.output_train = gen_normalize(self.input_train)%0A        if self.has_dropout_input:%0A            self.output_test = gen_normalize(self.input_test)%0A%0A    def get_output_shape(self):%0A        return image_shape%0A    %0A    def get_params(self):%0A        return %7B'provide_stdvar': self.provide_stdvar,%0A                'input_shape': self.image_shape,%0A                'provide_mean': self.provide_mean%0A               %7D%0A%0A    @staticmethod%0A    def build_layer_from_params(params, rng, input_train, input_test=None):%0A        layer = SimpleNormalizingLayer(input_train, input_test,%0A                                       params%5B'input_shape'%5D,%0A                                       params.get('provide_stdvar',None),%0A                                       params.get('provide_mean', None))%0A        return layer%0A%0A

add experimental simple normalization