summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nerv/examples/asr_trainer.lua23
-rw-r--r--nerv/examples/swb_baseline.lua7
-rw-r--r--nerv/examples/swb_baseline_basic.lua7
-rw-r--r--nerv/io/sgd_buffer.lua2
-rw-r--r--nerv/layer/mse.lua2
-rw-r--r--nerv/nn/layer_dag.lua27
6 files changed, 56 insertions, 12 deletions
diff --git a/nerv/examples/asr_trainer.lua b/nerv/examples/asr_trainer.lua
index dcadfa3..5a50542 100644
--- a/nerv/examples/asr_trainer.lua
+++ b/nerv/examples/asr_trainer.lua
@@ -3,6 +3,7 @@ function build_trainer(ifname)
param_repo:import(ifname, nil, gconf)
local layer_repo = make_layer_repo(param_repo)
local network = get_network(layer_repo)
+ local global_transf = get_global_transf(layer_repo)
local input_order = get_input_order()
local iterative_trainer = function (prefix, scp_file, bp)
gconf.randomize = bp
@@ -24,15 +25,29 @@ function build_trainer(ifname)
-- break
end
local input = {}
--- if gconf.cnt == 100 then break end
- for i, id in ipairs(input_order) do
+-- if gconf.cnt == 1000 then break end
+ for i, e in ipairs(input_order) do
+ local id = e.id
if data[id] == nil then
nerv.error("input data %s not found", id)
end
- table.insert(input, data[id])
+ local transformed
+ if e.global_transf then
+ transformed = nerv.speech_utils.global_transf(data[id],
+ global_transf,
+ gconf.frm_ext or 0,
+ gconf.frm_trim or 0,
+ gconf)
+ else
+ transformed = data[id]
+ end
+ table.insert(input, transformed)
end
local output = {nerv.CuMatrixFloat(gconf.batch_size, 1)}
- err_output = {input[1]:create()}
+ err_output = {}
+ for i = 1, #input do
+ table.insert(err_output, input[i]:create())
+ end
network:propagate(input, output)
if bp then
network:back_propagate(err_input, err_output, input, output)
diff --git a/nerv/examples/swb_baseline.lua b/nerv/examples/swb_baseline.lua
index 0e9f897..bbc6467 100644
--- a/nerv/examples/swb_baseline.lua
+++ b/nerv/examples/swb_baseline.lua
@@ -3,6 +3,7 @@ gconf = {lrate = 0.8, wcost = 1e-6, momentum = 0.9,
cumat_type = nerv.CuMatrixFloat,
mmat_type = nerv.MMatrixFloat,
frm_ext = 5,
+ frm_trim = 5,
tr_scp = "/slfs1/users/mfy43/swb_ivec/train_bp.scp",
cv_scp = "/slfs1/users/mfy43/swb_ivec/train_cv.scp",
htk_conf = "/slfs1/users/mfy43/swb_ivec/plp_0_d_a.conf",
@@ -161,8 +162,7 @@ function make_readers(scp_file, layer_repo)
dir = "*/",
ext = "lab"
}
- },
- global_transf = layer_repo:get_layer("global_transf")
+ }
}),
data = {main_scp = 429, phone_state = 1}}
}
@@ -178,7 +178,8 @@ function make_buffer(readers)
end
function get_input_order()
- return {"main_scp", "phone_state"}
+ return {{id = "main_scp", global_transf = true},
+ {id = "phone_state"}}
end
function get_accuracy(layer_repo)
diff --git a/nerv/examples/swb_baseline_basic.lua b/nerv/examples/swb_baseline_basic.lua
index c47ec3e..71f04a3 100644
--- a/nerv/examples/swb_baseline_basic.lua
+++ b/nerv/examples/swb_baseline_basic.lua
@@ -3,6 +3,7 @@ gconf = {lrate = 0.8, wcost = 1e-6, momentum = 0.9,
cumat_type = nerv.CuMatrixFloat,
mmat_type = nerv.MMatrixFloat,
frm_ext = 5,
+ frm_trim = 5,
tr_scp = "/slfs1/users/mfy43/swb_ivec/train_bp.scp",
cv_scp = "/slfs1/users/mfy43/swb_ivec/train_cv.scp",
htk_conf = "/slfs1/users/mfy43/swb_ivec/plp_0_d_a.conf",
@@ -124,8 +125,7 @@ function make_readers(scp_file, layer_repo)
dir = "*/",
ext = "lab"
}
- },
- global_transf = layer_repo:get_layer("global_transf")
+ }
}),
data = {main_scp = 429, phone_state = 1}}
}
@@ -141,7 +141,8 @@ function make_buffer(readers)
end
function get_input_order()
- return {"main_scp", "phone_state"}
+ return {{id = "main_scp", global_transf = true},
+ {id = "phone_state"}}
end
function get_accuracy(layer_repo)
diff --git a/nerv/io/sgd_buffer.lua b/nerv/io/sgd_buffer.lua
index 604fa07..f9d281c 100644
--- a/nerv/io/sgd_buffer.lua
+++ b/nerv/io/sgd_buffer.lua
@@ -91,7 +91,7 @@ function SGDBuffer:get_data()
if not self:saturate() then
return nil -- the remaining data cannot build a batch
end
- nerv.info("%.3fs to fill the buffer\n", os.clock() - t)
+ nerv.info("%.3fs to fill the buffer", os.clock() - t)
end
if self.head + batch_size > self.tail then
return nil -- the remaining data cannot build a batch
diff --git a/nerv/layer/mse.lua b/nerv/layer/mse.lua
index 9a97add..2516998 100644
--- a/nerv/layer/mse.lua
+++ b/nerv/layer/mse.lua
@@ -34,7 +34,7 @@ function MSELayer:propagate(input, output)
if output[1] ~= nil then
output[1]:copy_fromd(mse_sum)
end
- self.total_mse = self.total_mse + mse_sum:colsum()[0]
+ self.total_mse = self.total_mse + mse_sum:colsum()[0][0]
self.total_frames = self.total_frames + mse_sum:nrow()
end
diff --git a/nerv/nn/layer_dag.lua b/nerv/nn/layer_dag.lua
index e9d4d86..25297c2 100644
--- a/nerv/nn/layer_dag.lua
+++ b/nerv/nn/layer_dag.lua
@@ -254,3 +254,30 @@ function DAGLayer:get_params()
end
return nerv.ParamRepo.merge(param_repos)
end
+
+DAGLayer.PORT_TYPES = {
+ INPUT = {},
+ OUTPUT = {},
+ ERR_INPUT = {},
+ ERR_OUTPUT = {}
+}
+
+function DAGLayer:get_intermediate(id, port_type)
+ if id == "<input>" or id == "<output>" then
+ nerv.error("an actual real layer id is expected")
+ end
+ local layer = layers[id]
+ if layer == nil then
+ nerv.error("layer id %s not found", id)
+ end
+ if port_type == DAGLayer.PORT_TYPES.INPUT then
+ return layer.inputs
+ elseif port_type == DAGLayer.PORT_TYPES.OUTPUT then
+ return layer.outputs
+ elseif port_type == DAGLayer.PORT_TYPES.ERR_INPUT then
+ return layer.err_inputs
+ elseif port_type == DAGLayer.PORT_TYPES.ERR_OUTPUT then
+ return layer.err_outputs
+ end
+ nerv.error("unrecognized port type")
+end