making similar fix to nntrain as rbmtrain before. @barapa please check.