blob: 5b653a3f7006d77955c759277cfc8537285cea47 (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
local LSTMLayerT = nerv.class('nerv.LSTMLayerT', 'nerv.LayerT')
function LSTMLayerT:__init(id, gilobal_conf, layer_conf)
--input1:x input2:h input3:c
self.id = id
self.dim_in = layer_conf.dim_in
self.dim_out = layer_conf.dim_out
self.gconf = global_conf
--prepare a DAGLayerT to hold the lstm structure
local paramRepo = nerv.ParamRepo()
local layers = {
["nerv.IndRecurrentLayer"] = {
["recurrentL1"] = recurrentLconfig,
}}
self:check_dim_len(1, 1) -- exactly one input and one output
end
function LSTMLayerT:init(batch_size)
if self.ltp.trans:ncol() ~= self.bp.trans:ncol() then
nerv.error("mismatching dimensions of linear transform and bias paramter")
end
if self.dim_in[1] ~= self.ltp.trans:nrow() then
nerv.error("mismatching dimensions of linear transform parameter and input")
end
if self.dim_out[1] ~= self.ltp.trans:ncol() then
nerv.error("mismatching dimensions of linear transform parameter and output")
end
self.ltp_grad = self.ltp.trans:create()
self.ltp:train_init()
self.bp:train_init()
end
function LSTMLayerT:batch_resize(batch_size)
-- do nothing
end
function LSTMLayerT:update(bp_err, input, output)
end
function LSTMLayerT:propagate(input, output)
end
function LSTMLayerT:back_propagate(bp_err, next_bp_err, input, output)
end
function LSTMLayerT:get_params()
return nerv.ParamRepo({self.ltp, self.bp})
end
|