aboutsummaryrefslogtreecommitdiff
path: root/nerv/layer/window.lua
blob: 8eed3526526fc029d1db47f3500d9f02d03176e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
local WindowLayer = nerv.class("nerv.WindowLayer", "nerv.Layer")

function WindowLayer:__init(id, global_conf, layer_conf)
    self.id = id
    self.gconf = global_conf
    self.window = layer_conf.window
    self.dim_in = layer_conf.dim_in
    self.dim_out = layer_conf.dim_out
    self:check_dim_len(1, 1)
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_fromd(input[1])
    output[1]:scale_rows_by_row(self.window.trans)
end

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