blob: 8cd326bca8f5f894804fe611a022413cabab0d0e (
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
|
local BiasLayer = nerv.class("nerv.BiasLayer", "nerv.Layer")
function BiasLayer:__init(id, global_conf, layer_conf)
self.id = id
self.gconf = global_conf
self.bias = layer_conf.bias
self.dim_in = layer_conf.dim_in
self.dim_out = layer_conf.dim_out
self:check_dim_len(1, 1)
end
function BiasLayer:init()
if self.dim_in[1] ~= self.bias.trans:ncol() then
nerv.error("mismatching dimensions of input and bias parameter")
end
if self.dim_out[1] ~= self.bias.trans:ncol() then
nerv.error("mismatching dimensions of output and bias parameter")
end
end
function BiasLayer:propagate(input, output)
output[1]:copy_fromd(input[1])
output[1]:add_row(self.bias.trans, 1.0)
end
function BiasLayer:get_params()
return {self.bias}
end
|