aboutsummaryrefslogblamecommitdiff
path: root/nerv/layer/window.lua
blob: fb74b1461b13b5b960c3228a0acbfbc3be139080 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11


                                                                
                                                        
                            





                                                                   

                                                     


                                    










                                                                           



                                             
                                             
                                 
                                                  
   

                                 
                                                       
   





                                     
local WindowLayer = nerv.class("nerv.WindowLayer", "nerv.Layer")

function WindowLayer:__init(id, global_conf, layer_conf)
    nerv.Layer.__init(self, id, global_conf, layer_conf)
    self:check_dim_len(1, 1)
    self:bind_params()
end

function WindowLayer:bind_params()
    self.window = self:find_param("window", self.lconf, self.gconf,
                                nerv.BiasParam,
                                {1, self.dim_out[1]},
                                nerv.Param.gen_zero)
    if self.lconf.no_update_all then
        self.window.no_update = true
    end
end

function WindowLayer:init()
    if self.dim_in[1] ~= self.window.trans:ncol() then
        nerv.error("mismatching dimensions of input and window parameter")
    end
    if self.dim_out[1] ~= self.window.trans:ncol() then
        nerv.error("mismatching dimensions of output and window parameter")
    end
end

function WindowLayer:batch_resize(batch_size)
    -- do nothing
end

function WindowLayer:propagate(input, output)
    output[1]:copy_from(input[1])
    output[1]:scale_rows_by_row(self.window.trans)
end

function WindowLayer:get_params()
    return nerv.ParamRepo({self.window}, self.loc_type)
end

function WindowLayer:back_propagate()
end

function WindowLayer:update()
end