From 8e7d9453520840b6a5e269a101ca72b4a7ab36fa Mon Sep 17 00:00:00 2001 From: txh18 Date: Fri, 23 Oct 2015 20:58:27 +0800 Subject: lmptb can be run after merge from master --- nerv/examples/lmptb/lmptb/lmutil.lua | 5 +++++ nerv/examples/lmptb/main.lua | 13 ++++++++----- nerv/examples/lmptb/nerv | 4 +--- nerv/examples/lmptb/nerv-old | 3 --- 4 files changed, 14 insertions(+), 11 deletions(-) mode change 100755 => 120000 nerv/examples/lmptb/nerv delete mode 100755 nerv/examples/lmptb/nerv-old diff --git a/nerv/examples/lmptb/lmptb/lmutil.lua b/nerv/examples/lmptb/lmptb/lmutil.lua index 73cf041..7f45a49 100644 --- a/nerv/examples/lmptb/lmptb/lmutil.lua +++ b/nerv/examples/lmptb/lmptb/lmutil.lua @@ -102,6 +102,11 @@ function Result:ppl_all(cla) return math.pow(10, -(c.logp_all) / (c.cn_w + c.cn_sen)) end +function Result:logp_sample(cla) + local c = self[cla] + return c.logp_all / (c.cn_w + c.cn_sen) +end + function Result:status(cla) return "LMResult status of " .. cla .. ": " .. " " end diff --git a/nerv/examples/lmptb/main.lua b/nerv/examples/lmptb/main.lua index 8764998..74ce407 100644 --- a/nerv/examples/lmptb/main.lua +++ b/nerv/examples/lmptb/main.lua @@ -220,6 +220,7 @@ function propagateFile(global_conf, dagL, fn, config) end if (result["rnn"].cn_w % global_conf.log_w_num == 0) then printf("%s %d words processed %s.\n", global_conf.sche_log_pre, result["rnn"].cn_w, os.date()) + printf("\t%s log prob per sample :%f.\n", global_conf.sche_log_pre, result:logp_sample("rnn")); for key, value in pairs(global_conf.timer.rec) do printf("\t [global_conf.timer]: time spent on %s:%.5fs\n", key, value) end @@ -255,10 +256,11 @@ end local set = "ptb" if (set == "ptb") then - train_fn = "/slfs1/users/txh18/workspace/nerv-project/nerv/nerv/examples/lmptb/PTBdata/ptb.train.txt" - valid_fn = "/slfs1/users/txh18/workspace/nerv-project/nerv/nerv/examples/lmptb/PTBdata/ptb.valid.txt" - test_fn = "/slfs1/users/txh18/workspace/nerv-project/nerv/nerv/examples/lmptb/PTBdata/ptb.test.txt" - work_dir_base = "/slfs1/users/txh18/workspace/nerv-project/lmptb-work" + data_dir = "/home/slhome/txh18/workspace/nerv/nerv/nerv/examples/lmptb/PTBdata" + train_fn = data_dir.."/ptb.train.txt" + valid_fn = data_dir.."/ptb.valid.txt" + test_fn = data_dir.."/ptb.test.txt" + work_dir_base = "/home/slhome/txh18/workspace/nerv/lmptb-work" global_conf = { lrate = 1, wcost = 1e-6, momentum = 0, cumat_type = nerv.CuMatrixFloat, @@ -275,7 +277,7 @@ if (set == "ptb") then valid_fn = valid_fn, test_fn = test_fn, sche_log_pre = "[SCHEDULER]:", - log_w_num = 50000, --give a message when log_w_num words have been processed + log_w_num = 10000, --give a message when log_w_num words have been processed timer = nerv.Timer() } global_conf.work_dir = work_dir_base.."/h"..global_conf.hidden_size.."bp"..global_conf.bptt.."slr"..global_conf.lrate..os.date("_%bD%dH%H") @@ -323,6 +325,7 @@ os.execute("mkdir -p "..global_conf.work_dir) scheduler = " printf(\"===INITIAL VALIDATION===\\n\") \ dagL, paramRepo = load_net(global_conf) \ + printf(\"===INITIAL VALIDATION===\\n\") \ local result = propagateFile(global_conf, dagL, global_conf.valid_fn, {do_train = false, report_word = false}) \ ppl_rec = {} \ lr_rec = {} \ diff --git a/nerv/examples/lmptb/nerv b/nerv/examples/lmptb/nerv deleted file mode 100755 index 8829556..0000000 --- a/nerv/examples/lmptb/nerv +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec '/home/slhome/txh18/workspace/nerv-project/nerv-1/install/bin/luajit' -e 'package.path="/home/slhome/txh18/.luarocks/share/lua/5.1/?.lua;/home/slhome/txh18/.luarocks/share/lua/5.1/?/init.lua;/home/slhome/txh18/workspace/nerv-project/nerv-1/install/share/lua/5.1/?.lua;/home/slhome/txh18/workspace/nerv-project/nerv-1/install/share/lua/5.1/?/init.lua;"..package.path; package.cpath="/home/slhome/txh18/.luarocks/lib/lua/5.1/?.so;/home/slhome/txh18/workspace/nerv-project/nerv-1/install/lib/lua/5.1/?.so;"..package.cpath' -e 'local k,l,_=pcall(require,"luarocks.loader") _=k and l.add_context("nerv","scm-1")' '/home/slhome/txh18/workspace/nerv-project/nerv-1/install/lib/luarocks/rocks/nerv/scm-1/bin/nerv' "$@" diff --git a/nerv/examples/lmptb/nerv b/nerv/examples/lmptb/nerv new file mode 120000 index 0000000..e0dbb49 --- /dev/null +++ b/nerv/examples/lmptb/nerv @@ -0,0 +1 @@ +../../../install/bin/nerv \ No newline at end of file diff --git a/nerv/examples/lmptb/nerv-old b/nerv/examples/lmptb/nerv-old deleted file mode 100755 index 4912bed..0000000 --- a/nerv/examples/lmptb/nerv-old +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -NERV_PATH="../.." -exec "${NERV_PATH}/build/luajit-2.0/bin/luajit" -e "package.cpath=\"${NERV_PATH}/build/lib/?.so\"" -e "package.path=\"${NERV_PATH}/build/lua/?/init.lua;${NERV_PATH}/build/lua/?.lua;./?.lua;./?/init.lua\"" -e "require 'nerv'" "$@" -- cgit v1.2.3-70-g09d2