summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO.rst6
-rw-r--r--nerv/.gitignore1
-rw-r--r--nerv/config.ld4
-rw-r--r--nerv/doc/lua/index.html71
-rw-r--r--nerv/doc/lua/ldoc_pale.css304
-rw-r--r--nerv/doc/lua/modules/layer.affine.html145
-rw-r--r--nerv/doc/lua/modules/matrix.html409
-rw-r--r--nerv/doc/lua/modules/nerv.html428
-rw-r--r--nerv/matrix/init.lua9
-rw-r--r--nerv/nn/network.lua80
10 files changed, 85 insertions, 1372 deletions
diff --git a/TODO.rst b/TODO.rst
new file mode 100644
index 0000000..baeb7ba
--- /dev/null
+++ b/TODO.rst
@@ -0,0 +1,6 @@
+TODO List
+---------
+
+- NERV user manual
+- NERV overview and introduction
+- C header file dependency detection in Makefiles
diff --git a/nerv/.gitignore b/nerv/.gitignore
index 567609b..6b2f08b 100644
--- a/nerv/.gitignore
+++ b/nerv/.gitignore
@@ -1 +1,2 @@
build/
+doc/lua/
diff --git a/nerv/config.ld b/nerv/config.ld
index f60b53f..2cee84a 100644
--- a/nerv/config.ld
+++ b/nerv/config.ld
@@ -5,4 +5,6 @@ backtick_references = true
file = {'./', exclude = {'./lib/luaT'}}
dir = 'doc/lua'
style = '!pale'
-kind_names = {topic = 'Manual',script = 'Programs'}
+format = 'markdown'
+kind_names = {topic = 'Manual', script = 'Programs'}
+backtick_references = false
diff --git a/nerv/doc/lua/index.html b/nerv/doc/lua/index.html
deleted file mode 100644
index 56212cc..0000000
--- a/nerv/doc/lua/index.html
+++ /dev/null
@@ -1,71 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-<head>
- <title>NERV documentation</title>
- <link rel="stylesheet" href="ldoc_pale.css" type="text/css" />
-</head>
-<body>
-
-<div id="container">
-
-<div id="product">
- <div id="product_logo"></div>
- <div id="product_name"><big><b></b></big></div>
- <div id="product_description"></div>
-</div> <!-- id="product" -->
-
-
-<div id="main">
-
-
-<!-- Menu -->
-
-<div id="navigation">
-<br/>
-<h1>NERV</h1>
-
-
-
-
-<h2>Modules</h2>
-<ul class="$(kind=='Topics' and '' or 'nowrap'">
- <li><a href="modules/nerv.html">nerv</a></li>
- <li><a href="modules/layer.affine.html">layer.affine</a></li>
- <li><a href="modules/matrix.html">matrix</a></li>
-</ul>
-
-</div>
-
-<div id="content">
-
-
- <h2>A Lua-based toolkit for high-performance deep learning</h2>
-
-<h2>Modules</h2>
-<table class="module_list">
- <tr>
- <td class="name" nowrap><a href="modules/nerv.html">nerv</a></td>
- <td class="summary">NERV: a Lua-based toolkit for high-performance deep learning.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="modules/layer.affine.html">layer.affine</a></td>
- <td class="summary">Parameter and layer classes related to linear transform.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="modules/matrix.html">matrix</a></td>
- <td class="summary">Implements a fraction of matrix operations (methods) in Lua, while
- others are implemented in C extension.</td>
- </tr>
-</table>
-
-</div> <!-- id="content" -->
-</div> <!-- id="main" -->
-<div id="about">
-<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
-<i style="float:right;">Last updated 2016-01-15 14:56:30 </i>
-</div> <!-- id="about" -->
-</div> <!-- id="container" -->
-</body>
-</html>
diff --git a/nerv/doc/lua/ldoc_pale.css b/nerv/doc/lua/ldoc_pale.css
deleted file mode 100644
index b071110..0000000
--- a/nerv/doc/lua/ldoc_pale.css
+++ /dev/null
@@ -1,304 +0,0 @@
-/* BEGIN RESET
-
-Copyright (c) 2010, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.com/yui/license.html
-version: 2.8.2r1
-*/
-html {
- color: #000;
- background: #FFF;
-}
-body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td {
- margin: 0;
- padding: 0;
-}
-table {
- border-collapse: collapse;
- border-spacing: 0;
-}
-fieldset,img {
- border: 0;
-}
-address,caption,cite,code,dfn,em,strong,th,var,optgroup {
- font-style: inherit;
- font-weight: inherit;
-}
-del,ins {
- text-decoration: none;
-}
-li {
- list-style: disc;
- margin-left: 20px;
-}
-caption,th {
- text-align: left;
-}
-h1,h2,h3,h4,h5,h6 {
- font-size: 100%;
- font-weight: bold;
-}
-q:before,q:after {
- content: '';
-}
-abbr,acronym {
- border: 0;
- font-variant: normal;
-}
-sup {
- vertical-align: baseline;
-}
-sub {
- vertical-align: baseline;
-}
-legend {
- color: #000;
-}
-input,button,textarea,select,optgroup,option {
- font-family: inherit;
- font-size: inherit;
- font-style: inherit;
- font-weight: inherit;
-}
-input,button,textarea,select {*font-size:100%;
-}
-/* END RESET */
-
-body {
- margin-left: 1em;
- margin-right: 1em;
- font-family: arial, helvetica, geneva, sans-serif;
- background-color: #ffffff; margin: 0px;
-}
-
-code, tt { font-family: monospace; font-size: 1.1em; }
-span.parameter { font-family:monospace; }
-span.parameter:after { content:":"; }
-span.types:before { content:"("; }
-span.types:after { content:")"; }
-.type { font-weight: bold; font-style:italic }
-
-body, p, td, th { font-size: .95em; line-height: 1.2em;}
-
-p, ul { margin: 10px 0 0 0px;}
-
-strong { font-weight: bold;}
-
-em { font-style: italic;}
-
-h1 {
- font-size: 1.5em;
- margin: 0 0 20px 0;
-}
-h2, h3, h4 { margin: 15px 0 10px 0; }
-h2 { font-size: 1.25em; }
-h3 { font-size: 1.15em; }
-h4 { font-size: 1.06em; }
-
-a:link { font-weight: bold; color: #004080; text-decoration: none; }
-a:visited { font-weight: bold; color: #006699; text-decoration: none; }
-a:link:hover { text-decoration: underline; }
-
-hr {
- color:#cccccc;
- background: #00007f;
- height: 1px;
-}
-
-blockquote { margin-left: 3em; }
-
-ul { list-style-type: disc; }
-
-p.name {
- font-family: "Andale Mono", monospace;
- padding-top: 1em;
-}
-
-pre {
- background-color: rgb(245, 245, 245);
- border: 1px solid #C0C0C0; /* silver */
- padding: 10px;
- margin: 10px 0 10px 0;
- overflow: auto;
- font-family: "Andale Mono", monospace;
-}
-
-pre.example {
- font-size: .85em;
-}
-
-table.index { border: 1px #00007f; }
-table.index td { text-align: left; vertical-align: top; }
-
-#container {
- margin-left: 1em;
- margin-right: 1em;
- background-color: #ffffff;
-}
-
-#product {
- text-align: center;
- border-bottom: 1px solid #cccccc;
- background-color: #ffffff;
-}
-
-#product big {
- font-size: 2em;
-}
-
-#main {
- background-color:#FFFFFF; // #f0f0f0;
- //border-left: 2px solid #cccccc;
-}
-
-#navigation {
- float: left;
- width: 14em;
- vertical-align: top;
- background-color:#FFFFFF; // #f0f0f0;
- border-right: 2px solid #cccccc;
- overflow: visible;
-}
-
-#navigation h2 {
- background-color:#FFFFFF;//:#e7e7e7;
- font-size:1.1em;
- color:#000000;
- text-align: left;
- padding:0.2em;
- //border-top:1px solid #dddddd;
- border-bottom:1px solid #dddddd;
-}
-
-#navigation ul
-{
- font-size:1em;
- list-style-type: none;
- margin: 1px 1px 10px 1px;
-}
-
-#navigation li {
- text-indent: -1em;
- display: block;
- margin: 3px 0px 0px 22px;
-}
-
-#navigation li li a {
- margin: 0px 3px 0px -1em;
-}
-
-#content {
- margin-left: 14em;
- padding: 1em;
- width: 700px;
- border-left: 2px solid #cccccc;
- // border-right: 2px solid #cccccc;
- background-color: #ffffff;
-}
-
-#about {
- clear: both;
- padding: 5px;
- border-top: 2px solid #cccccc;
- background-color: #ffffff;
-}
-
-@media print {
- body {
- font: 12pt "Times New Roman", "TimeNR", Times, serif;
- }
- a { font-weight: bold; color: #004080; text-decoration: underline; }
-
- #main {
- background-color: #ffffff;
- border-left: 0px;
- }
-
- #container {
- margin-left: 2%;
- margin-right: 2%;
- background-color: #ffffff;
- }
-
- #content {
- padding: 1em;
- background-color: #ffffff;
- }
-
- #navigation {
- display: none;
- }
- pre.example {
- font-family: "Andale Mono", monospace;
- font-size: 10pt;
- page-break-inside: avoid;
- }
-}
-
-table.module_list {
- border-width: 1px;
- border-style: solid;
- border-color: #cccccc;
- border-collapse: collapse;
-}
-table.module_list td {
- border-width: 1px;
- padding: 3px;
- border-style: solid;
- border-color: #cccccc;
-}
-table.module_list td.name { background-color: #f0f0f0; ; min-width: 200px; }
-table.module_list td.summary { width: 100%; }
-
-table.function_list {
- border-width: 1px;
- border-style: solid;
- border-color: #cccccc;
- border-collapse: collapse;
-}
-table.function_list td {
- border-width: 1px;
- padding: 3px;
- border-style: solid;
- border-color: #cccccc;
-}
-table.function_list td.name { background-color: #f6f6ff; ; min-width: 200px; }
-table.function_list td.summary { width: 100%; }
-
-dl.table dt, dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;}
-dl.table dd, dl.function dd {padding-bottom: 1em; margin: 10px 0 0 20px;}
-dl.table h3, dl.function h3 {font-size: .95em;}
-
-ul.nowrap {
- overflow:auto;
- whitespace:nowrap;
-}
-
-/* stop sublists from having initial vertical space */
-ul ul { margin-top: 0px; }
-ol ul { margin-top: 0px; }
-ol ol { margin-top: 0px; }
-ul ol { margin-top: 0px; }
-
-/* make the target distinct; helps when we're navigating to a function */
-a:target + * {
- background-color: #FF9;
-}
-
-
-/* styles for prettification of source */
-pre .comment { color: #558817; }
-pre .constant { color: #a8660d; }
-pre .escape { color: #844631; }
-pre .keyword { color: #aa5050; font-weight: bold; }
-pre .library { color: #0e7c6b; }
-pre .marker { color: #512b1e; background: #fedc56; font-weight: bold; }
-pre .string { color: #8080ff; }
-pre .number { color: #f8660d; }
-pre .operator { color: #2239a8; font-weight: bold; }
-pre .preprocessor, pre .prepro { color: #a33243; }
-pre .global { color: #800080; }
-pre .user-keyword { color: #800080; }
-pre .prompt { color: #558817; }
-pre .url { color: #272fc2; text-decoration: underline; }
-
diff --git a/nerv/doc/lua/modules/layer.affine.html b/nerv/doc/lua/modules/layer.affine.html
deleted file mode 100644
index 817fc37..0000000
--- a/nerv/doc/lua/modules/layer.affine.html
+++ /dev/null
@@ -1,145 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-<head>
- <title>NERV documentation</title>
- <link rel="stylesheet" href="../ldoc_pale.css" type="text/css" />
-</head>
-<body>
-
-<div id="container">
-
-<div id="product">
- <div id="product_logo"></div>
- <div id="product_name"><big><b></b></big></div>
- <div id="product_description"></div>
-</div> <!-- id="product" -->
-
-
-<div id="main">
-
-
-<!-- Menu -->
-
-<div id="navigation">
-<br/>
-<h1>NERV</h1>
-
-<ul>
- <li><a href="../index.html">Index</a></li>
-</ul>
-
-<h2>Contents</h2>
-<ul>
-<li><a href="#Class_nerv_MatrixParam">Class nerv.MatrixParam </a></li>
-<li><a href="#Class_nerv_AffineLayer">Class nerv.AffineLayer </a></li>
-</ul>
-
-
-<h2>Modules</h2>
-<ul class="$(kind=='Topics' and '' or 'nowrap'">
- <li><a href="../modules/nerv.html">nerv</a></li>
- <li><strong>layer.affine</strong></li>
- <li><a href="../modules/matrix.html">matrix</a></li>
-</ul>
-
-</div>
-
-<div id="content">
-
-<h1>Module <code>layer.affine</code></h1>
-<p>Parameter and layer classes related to linear transform.</p>
-<p></p>
-
-
-<h2><a href="#Class_nerv_MatrixParam">Class nerv.MatrixParam </a></h2>
-<table class="function_list">
- <tr>
- <td class="name" nowrap><a href="#MatrixParam:read">MatrixParam:read (handle)</a></td>
- <td class="summary">Read from a file handle.</td>
- </tr>
-</table>
-<h2><a href="#Class_nerv_AffineLayer">Class nerv.AffineLayer </a></h2>
-<table class="function_list">
- <tr>
- <td class="name" nowrap><a href="#AffineLayer:__init">AffineLayer:__init (id, global_conf, layer_conf)</a></td>
- <td class="summary">The constructor.</td>
- </tr>
-</table>
-
-<br/>
-<br/>
-
-
- <h2 class="section-header has-description"><a name="Class_nerv_MatrixParam"></a>Class nerv.MatrixParam </h2>
-
- <div class="section-description">
- A parameter that consists of a single matrix
- </div>
- <dl class="function">
- <dt>
- <a name = "MatrixParam:read"></a>
- <strong>MatrixParam:read (handle)</strong>
- </dt>
- <dd>
- Read from a file handle.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">handle</span>
- the file handle
- </li>
- </ul>
-
-
-
-
-
-</dd>
-</dl>
- <h2 class="section-header has-description"><a name="Class_nerv_AffineLayer"></a>Class nerv.AffineLayer </h2>
-
- <div class="section-description">
- A fully-connected linear transform layer.
- </div>
- <dl class="function">
- <dt>
- <a name = "AffineLayer:__init"></a>
- <strong>AffineLayer:__init (id, global_conf, layer_conf)</strong>
- </dt>
- <dd>
- The constructor.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">id</span>
-
- </li>
- <li><span class="parameter">global_conf</span>
-
- </li>
- <li><span class="parameter">layer_conf</span>
-
- </li>
- </ul>
-
-
-
-
-
-</dd>
-</dl>
-
-
-</div> <!-- id="content" -->
-</div> <!-- id="main" -->
-<div id="about">
-<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
-<i style="float:right;">Last updated 2016-01-15 14:56:30 </i>
-</div> <!-- id="about" -->
-</div> <!-- id="container" -->
-</body>
-</html>
diff --git a/nerv/doc/lua/modules/matrix.html b/nerv/doc/lua/modules/matrix.html
deleted file mode 100644
index 2840e59..0000000
--- a/nerv/doc/lua/modules/matrix.html
+++ /dev/null
@@ -1,409 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-<head>
- <title>NERV documentation</title>
- <link rel="stylesheet" href="../ldoc_pale.css" type="text/css" />
-</head>
-<body>
-
-<div id="container">
-
-<div id="product">
- <div id="product_logo"></div>
- <div id="product_name"><big><b></b></big></div>
- <div id="product_description"></div>
-</div> <!-- id="product" -->
-
-
-<div id="main">
-
-
-<!-- Menu -->
-
-<div id="navigation">
-<br/>
-<h1>NERV</h1>
-
-<ul>
- <li><a href="../index.html">Index</a></li>
-</ul>
-
-<h2>Contents</h2>
-<ul>
-<li><a href="#Class_nerv_Matrix">Class nerv.Matrix </a></li>
-<li><a href="#Class_nerv_CuMatrixFloat">Class nerv.CuMatrixFloat </a></li>
-<li><a href="#Class_nerv_CuMatrixDouble">Class nerv.CuMatrixDouble </a></li>
-<li><a href="#Class_nerv_MMatrix">Class nerv.MMatrix </a></li>
-</ul>
-
-
-<h2>Modules</h2>
-<ul class="$(kind=='Topics' and '' or 'nowrap'">
- <li><a href="../modules/nerv.html">nerv</a></li>
- <li><a href="../modules/layer.affine.html">layer.affine</a></li>
- <li><strong>matrix</strong></li>
-</ul>
-
-</div>
-
-<div id="content">
-
-<h1>Module <code>matrix</code></h1>
-<p>Implements a fraction of matrix operations (methods) in Lua, while
- others are implemented in C extension.</p>
-<p></p>
- <h3>Info:</h3>
- <ul>
- <li><strong>Author</strong>: Ted Yin <[email protected]></li>
- </ul>
-
-
-<h2><a href="#Class_nerv_Matrix">Class nerv.Matrix </a></h2>
-<table class="function_list">
- <tr>
- <td class="name" nowrap><a href="#nerv.Matrix:__tostring__">nerv.Matrix:__tostring__ ()</a></td>
- <td class="summary">Convert the matrix object to a string.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#nerv.Matrix:generate">nerv.Matrix:generate (gen)</a></td>
- <td class="summary">Assign each element in a matrix using the value returned by a callback <code>gen</code>.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#nerv.Matrix:create">nerv.Matrix:create (nrow, ncol)</a></td>
- <td class="summary">Create a fresh new matrix of the same matrix type (as <code>self</code>).</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#nerv.Matrix:__add__">nerv.Matrix:__add__ (b)</a></td>
- <td class="summary">Operator overloading of <code>+</code>.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#nerv.Matrix:__sub__">nerv.Matrix:__sub__ (b)</a></td>
- <td class="summary">Operator overloading of <code>-</code>.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#nerv.Matrix:__mul__">nerv.Matrix:__mul__ (b)</a></td>
- <td class="summary">Operator overloading of <code>*</code>.</td>
- </tr>
-</table>
-<h2><a href="#Class_nerv_CuMatrixFloat">Class nerv.CuMatrixFloat </a></h2>
-<table class="function_list">
- <tr>
- <td class="name" nowrap><a href="#nerv.CuMatrixFloat.new_from_host">nerv.CuMatrixFloat.new_from_host (mat)</a></td>
- <td class="summary">Create a CUDA matrix copy of the host matrix (in memory)</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#nerv.CuMatrixFloat:new_to_host">nerv.CuMatrixFloat:new_to_host ()</a></td>
- <td class="summary">Create a host matrix copy of the CUDA matrix</td>
- </tr>
-</table>
-<h2><a href="#Class_nerv_CuMatrixDouble">Class nerv.CuMatrixDouble </a></h2>
-<table class="function_list">
- <tr>
- <td class="name" nowrap><a href="#nerv.CuMatrixDouble.new_from_host">nerv.CuMatrixDouble.new_from_host (mat)</a></td>
- <td class="summary">Create a CUDA matrix copy of the host matrix (in memory)</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#nerv.CuMatrixDouble:new_to_host">nerv.CuMatrixDouble:new_to_host ()</a></td>
- <td class="summary">Create a host matrix copy of the CUDA matrix</td>
- </tr>
-</table>
-<h2><a href="#Class_nerv_MMatrix">Class nerv.MMatrix </a></h2>
-<table class="function_list">
- <tr>
- <td class="name" nowrap><a href="#nerv.MMatrix:copy_toh">nerv.MMatrix:copy_toh (b, ...)</a></td>
- <td class="summary">A wrapper function for <code>copy_fromh</code></td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#nerv.MMatrix.print_profile">nerv.MMatrix.print_profile ()</a></td>
- <td class="summary">Print profiling info of host matrices</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#nerv.MMatrix.clear_profile">nerv.MMatrix.clear_profile ()</a></td>
- <td class="summary">Clear profiling info of host matrices</td>
- </tr>
-</table>
-
-<br/>
-<br/>
-
-
- <h2 class="section-header has-description"><a name="Class_nerv_Matrix"></a>Class nerv.Matrix </h2>
-
- <div class="section-description">
- The base class for all matrices.
- </div>
- <dl class="function">
- <dt>
- <a name = "nerv.Matrix:__tostring__"></a>
- <strong>nerv.Matrix:__tostring__ ()</strong>
- </dt>
- <dd>
- Convert the matrix object to a string.
-
-
-
-
-
-
-
-</dd>
- <dt>
- <a name = "nerv.Matrix:generate"></a>
- <strong>nerv.Matrix:generate (gen)</strong>
- </dt>
- <dd>
- Assign each element in a matrix using the value returned by a callback <code>gen</code>.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">gen</span>
- the callback used to generated the values in the matrix, to which
- the indices of row and column will be passed (e.g., <code>gen(i, j)</code>)
- </li>
- </ul>
-
-
-
-
-
-</dd>
- <dt>
- <a name = "nerv.Matrix:create"></a>
- <strong>nerv.Matrix:create (nrow, ncol)</strong>
- </dt>
- <dd>
- Create a fresh new matrix of the same matrix type (as <code>self</code>).
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">nrow</span>
- optional, the number of rows in the created matrix if specified,
- otherwise <code>self:nrow()</code> will be used
- </li>
- <li><span class="parameter">ncol</span>
- optional, the number of columns in the created matrix if specified,
- otherwise <code>self:ncol()</code> will be used
- </li>
- </ul>
-
-
-
-
-
-</dd>
- <dt>
- <a name = "nerv.Matrix:__add__"></a>
- <strong>nerv.Matrix:__add__ (b)</strong>
- </dt>
- <dd>
- Operator overloading of <code>+</code>.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">b</span>
-
- </li>
- </ul>
-
-
-
-
-
-</dd>
- <dt>
- <a name = "nerv.Matrix:__sub__"></a>
- <strong>nerv.Matrix:__sub__ (b)</strong>
- </dt>
- <dd>
- Operator overloading of <code>-</code>.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">b</span>
-
- </li>
- </ul>
-
-
-
-
-
-</dd>
- <dt>
- <a name = "nerv.Matrix:__mul__"></a>
- <strong>nerv.Matrix:__mul__ (b)</strong>
- </dt>
- <dd>
- Operator overloading of <code>*</code>.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">b</span>
-
- </li>
- </ul>
-
-
-
-
-
-</dd>
-</dl>
- <h2 class="section-header has-description"><a name="Class_nerv_CuMatrixFloat"></a>Class nerv.CuMatrixFloat </h2>
-
- <div class="section-description">
- CUDA float matrices
- </div>
- <dl class="function">
- <dt>
- <a name = "nerv.CuMatrixFloat.new_from_host"></a>
- <strong>nerv.CuMatrixFloat.new_from_host (mat)</strong>
- </dt>
- <dd>
- Create a CUDA matrix copy of the host matrix (in memory)
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">mat</span>
- the host matrix
- </li>
- </ul>
-
-
-
-
-
-</dd>
- <dt>
- <a name = "nerv.CuMatrixFloat:new_to_host"></a>
- <strong>nerv.CuMatrixFloat:new_to_host ()</strong>
- </dt>
- <dd>
- Create a host matrix copy of the CUDA matrix
-
-
-
-
-
-
-
-</dd>
-</dl>
- <h2 class="section-header has-description"><a name="Class_nerv_CuMatrixDouble"></a>Class nerv.CuMatrixDouble </h2>
-
- <div class="section-description">
- CUDA double matrices
- </div>
- <dl class="function">
- <dt>
- <a name = "nerv.CuMatrixDouble.new_from_host"></a>
- <strong>nerv.CuMatrixDouble.new_from_host (mat)</strong>
- </dt>
- <dd>
- Create a CUDA matrix copy of the host matrix (in memory)
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">mat</span>
- the host matrix
- </li>
- </ul>
-
-
-
-
-
-</dd>
- <dt>
- <a name = "nerv.CuMatrixDouble:new_to_host"></a>
- <strong>nerv.CuMatrixDouble:new_to_host ()</strong>
- </dt>
- <dd>
- Create a host matrix copy of the CUDA matrix
-
-
-
-
-
-
-
-</dd>
-</dl>
- <h2 class="section-header has-description"><a name="Class_nerv_MMatrix"></a>Class nerv.MMatrix </h2>
-
- <div class="section-description">
- The base class for all host (in-memory) matrices
- </div>
- <dl class="function">
- <dt>
- <a name = "nerv.MMatrix:copy_toh"></a>
- <strong>nerv.MMatrix:copy_toh (b, ...)</strong>
- </dt>
- <dd>
- A wrapper function for <code>copy_fromh</code>
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">b</span>
-
- </li>
- <li><span class="parameter">...</span>
-
- </li>
- </ul>
-
-
-
-
-
-</dd>
- <dt>
- <a name = "nerv.MMatrix.print_profile"></a>
- <strong>nerv.MMatrix.print_profile ()</strong>
- </dt>
- <dd>
- Print profiling info of host matrices
-
-
-
-
-
-
-
-</dd>
- <dt>
- <a name = "nerv.MMatrix.clear_profile"></a>
- <strong>nerv.MMatrix.clear_profile ()</strong>
- </dt>
- <dd>
- Clear profiling info of host matrices
-
-
-
-
-
-
-
-</dd>
-</dl>
-
-
-</div> <!-- id="content" -->
-</div> <!-- id="main" -->
-<div id="about">
-<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
-<i style="float:right;">Last updated 2016-01-15 14:56:30 </i>
-</div> <!-- id="about" -->
-</div> <!-- id="container" -->
-</body>
-</html>
diff --git a/nerv/doc/lua/modules/nerv.html b/nerv/doc/lua/modules/nerv.html
deleted file mode 100644
index 91baf9e..0000000
--- a/nerv/doc/lua/modules/nerv.html
+++ /dev/null
@@ -1,428 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-<head>
- <title>NERV documentation</title>
- <link rel="stylesheet" href="../ldoc_pale.css" type="text/css" />
-</head>
-<body>
-
-<div id="container">
-
-<div id="product">
- <div id="product_logo"></div>
- <div id="product_name"><big><b></b></big></div>
- <div id="product_description"></div>
-</div> <!-- id="product" -->
-
-
-<div id="main">
-
-
-<!-- Menu -->
-
-<div id="navigation">
-<br/>
-<h1>NERV</h1>
-
-<ul>
- <li><a href="../index.html">Index</a></li>
-</ul>
-
-<h2>Contents</h2>
-<ul>
-<li><a href="#Functions">Functions</a></li>
-</ul>
-
-
-<h2>Modules</h2>
-<ul class="$(kind=='Topics' and '' or 'nowrap'">
- <li><strong>nerv</strong></li>
- <li><a href="../modules/layer.affine.html">layer.affine</a></li>
- <li><a href="../modules/matrix.html">matrix</a></li>
-</ul>
-
-</div>
-
-<div id="content">
-
-<h1>Module <code>nerv</code></h1>
-<p>NERV: a Lua-based toolkit for high-performance deep learning.</p>
-<p>
- This file contains misc utility functions of NERV and finally initializes
- NERV by including <code>init.lua</code> of other basic modules.</p>
- <h3>Info:</h3>
- <ul>
- <li><strong>Author</strong>: Ted Yin <[email protected]></li>
- </ul>
-
-
-<h2><a href="#Functions">Functions</a></h2>
-<table class="function_list">
- <tr>
- <td class="name" nowrap><a href="#error_method_not_implemented">error_method_not_implemented ()</a></td>
- <td class="summary">Dummy function.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#sprintf">sprintf (fmt, ...)</a></td>
- <td class="summary">Format a string just like <a href="../modules/nerv.html#sprintf">sprintf</a> in C.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#printf">printf (fmt, ...)</a></td>
- <td class="summary">Print a formatted string to stdout.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#error">error (fmt, ...)</a></td>
- <td class="summary">Raise an global error with the formatted message.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#info">info (fmt, ...)</a></td>
- <td class="summary">Print a notification message that begins with "info" and a timestamp.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#warning">warning (fmt, ...)</a></td>
- <td class="summary">Print a warning message that begins with "warning" and a timestamp.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#class">class (tname, parenttname)</a></td>
- <td class="summary">Create a class (Torch-compatible).</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#table.tostring">table.tostring (tbl)</a></td>
- <td class="summary">Get the string representation of a table, which can be executed as a valid
- piece of Lua code.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#get_type">get_type (tname)</a></td>
- <td class="summary">Get the class by name.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#is_type">is_type (obj, tname)</a></td>
- <td class="summary">Check if the object is of the certain class.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#dirname">dirname (filename)</a></td>
- <td class="summary">Strip last component from file name.</td>
- </tr>
- <tr>
- <td class="name" nowrap><a href="#include">include (filename)</a></td>
- <td class="summary">Include a script file (chunk) into the current script.</td>
- </tr>
-</table>
-
-<br/>
-<br/>
-
-
- <h2 class="section-header "><a name="Functions"></a>Functions</h2>
-
- <dl class="function">
- <dt>
- <a name = "error_method_not_implemented"></a>
- <strong>error_method_not_implemented ()</strong>
- </dt>
- <dd>
- Dummy function.
- Display a friendly error message when user attempts to invoke a
- non-implemented function.
-
-
-
-
-
-
-
-</dd>
- <dt>
- <a name = "sprintf"></a>
- <strong>sprintf (fmt, ...)</strong>
- </dt>
- <dd>
- Format a string just like <a href="../modules/nerv.html#sprintf">sprintf</a> in C.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">fmt</span>
- the format string
- </li>
- <li><span class="parameter">...</span>
- args, the data to be formatted
- </li>
- </ul>
-
- <h3>Returns:</h3>
- <ol>
-
- the formatted string
- </ol>
-
-
-
-
-</dd>
- <dt>
- <a name = "printf"></a>
- <strong>printf (fmt, ...)</strong>
- </dt>
- <dd>
- Print a formatted string to stdout.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">fmt</span>
- the format string
- </li>
- <li><span class="parameter">...</span>
- args, the data to be formatted
- </li>
- </ul>
-
-
-
-
-
-</dd>
- <dt>
- <a name = "error"></a>
- <strong>error (fmt, ...)</strong>
- </dt>
- <dd>
- Raise an global error with the formatted message.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">fmt</span>
- the format string
- </li>
- <li><span class="parameter">...</span>
- args, the data to be formatted
- </li>
- </ul>
-
-
-
-
-
-</dd>
- <dt>
- <a name = "info"></a>
- <strong>info (fmt, ...)</strong>
- </dt>
- <dd>
- Print a notification message that begins with "info" and a timestamp.
- Instead of using <a href="../modules/nerv.html#printf">nerv.printf</a>, normal users should use this to print any
- notification information.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">fmt</span>
- the format string
- </li>
- <li><span class="parameter">...</span>
- args, the data to be formatted
- </li>
- </ul>
-
-
-
-
-
-</dd>
- <dt>
- <a name = "warning"></a>
- <strong>warning (fmt, ...)</strong>
- </dt>
- <dd>
- Print a warning message that begins with "warning" and a timestamp.
- Instead of using <a href="../modules/nerv.html#printf">nerv.printf</a>, normal users should use this to print any
- warnings.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">fmt</span>
- the format string
- </li>
- <li><span class="parameter">...</span>
- args, the data to be formatted
- </li>
- </ul>
-
-
-
-
-
-</dd>
- <dt>
- <a name = "class"></a>
- <strong>class (tname, parenttname)</strong>
- </dt>
- <dd>
- Create a class (Torch-compatible).
- Use this to create a class in NERV.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">tname</span>
- the class name
- </li>
- <li><span class="parameter">parenttname</span>
- the parent class name (from which it inherits)
- </li>
- </ul>
-
- <h3>Returns:</h3>
- <ol>
-
- the created class
- </ol>
-
-
-
-
-</dd>
- <dt>
- <a name = "table.tostring"></a>
- <strong>table.tostring (tbl)</strong>
- </dt>
- <dd>
- Get the string representation of a table, which can be executed as a valid
- piece of Lua code.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">tbl</span>
- the table
- </li>
- </ul>
-
- <h3>Returns:</h3>
- <ol>
-
- the string representation which will result in a Lua table entity
- when evaluated
- </ol>
-
-
-
-
-</dd>
- <dt>
- <a name = "get_type"></a>
- <strong>get_type (tname)</strong>
- </dt>
- <dd>
- Get the class by name.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">tname</span>
- the name of the class
- </li>
- </ul>
-
- <h3>Returns:</h3>
- <ol>
-
- the class entity
- </ol>
-
-
-
-
-</dd>
- <dt>
- <a name = "is_type"></a>
- <strong>is_type (obj, tname)</strong>
- </dt>
- <dd>
- Check if the object is of the certain class.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">obj</span>
- the object ("class instance")
- </li>
- <li><span class="parameter">tname</span>
- the class name ("type name")
- </li>
- </ul>
-
-
-
-
-
-</dd>
- <dt>
- <a name = "dirname"></a>
- <strong>dirname (filename)</strong>
- </dt>
- <dd>
- Strip last component from file name.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">filename</span>
- the path to a file
- </li>
- </ul>
-
- <h3>Returns:</h3>
- <ol>
-
- the path to the containing directory
- </ol>
-
-
-
-
-</dd>
- <dt>
- <a name = "include"></a>
- <strong>include (filename)</strong>
- </dt>
- <dd>
- Include a script file (chunk) into the current script.
- An analogy to <code>#include</code> in C. Note that the effect is the same as executing
- <code>dofile(filename)</code> at the current line.
-
-
- <h3>Parameters:</h3>
- <ul>
- <li><span class="parameter">filename</span>
- the path to a file
- </li>
- </ul>
-
- <h3>Returns:</h3>
- <ol>
-
- all values returned by the chunk
- </ol>
-
-
-
-
-</dd>
-</dl>
-
-
-</div> <!-- id="content" -->
-</div> <!-- id="main" -->
-<div id="about">
-<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
-<i style="float:right;">Last updated 2016-01-15 14:56:30 </i>
-</div> <!-- id="about" -->
-</div> <!-- id="container" -->
-</body>
-</html>
diff --git a/nerv/matrix/init.lua b/nerv/matrix/init.lua
index 722c780..5d0544a 100644
--- a/nerv/matrix/init.lua
+++ b/nerv/matrix/init.lua
@@ -37,10 +37,6 @@ function nerv.Matrix:__tostring__()
return table.concat(strt)
end
---- Assign each element in a matrix using the value returned by a callback `gen`.
--- @param gen the callback used to generated the values in the matrix, to which
--- the indices of row and column will be passed (e.g., `gen(i, j)`)
-
function nerv.Matrix:_generate(gen)
if (self:dim() == 2) then
for i = 0, self:nrow() - 1 do
@@ -51,11 +47,14 @@ function nerv.Matrix:_generate(gen)
end
else
for j = 0, self:ncol() - 1 do
- self[j] = gen(j)
+ self[j] = gen(j)
end
end
end
+--- Assign each element in a matrix using the value returned by a callback `gen`.
+-- @param gen the callback used to generated the values in the matrix, to which
+-- the indices of row and column will be passed (e.g., `gen(i, j)`)
function nerv.Matrix:generate(gen)
local tmp
if nerv.is_type(self, 'nerv.CuMatrixFloat') then
diff --git a/nerv/nn/network.lua b/nerv/nn/network.lua
index cf6a4d3..19fa9d3 100644
--- a/nerv/nn/network.lua
+++ b/nerv/nn/network.lua
@@ -1,5 +1,43 @@
+--- Implements the concept of computable but opaque networks built ("compiled")
+-- from nested layers
+-- @author Qi Liu <[email protected]>
+-- @author Ted Yin <[email protected]>
+
+--- The class describing a computable but opaque network built from nested
+-- layers.
+-- @type nerv.Network
+
local network = nerv.class('nerv.Network')
+--- The constructor.
+-- @param id the identifier of the network (currently having no effects)
+-- @param global_conf a table describing the computation state and providing
+-- with some global settings
+--
+-- The following fields in `global_conf` will be used:
+--
+-- * `use_cpu`: whether to use CPU for the computation
+-- * `mmat_type`: the class used for creating matrices in CPU computation
+-- * `cumat_type` (if `use_cpu = false`): the class used for creating matrices
+-- in GPU computation
+--
+-- The following fields in `global_conf` will be altered:
+--
+-- * `mask`: an array of `chunk_size` length containing column binary vectors
+-- indicating whether each frame in a *batch matrix* (i.e. one matrix in a BPTT
+-- chunk/"mini-batch") contains a valid data (1 indicates data, 0 indicates
+-- holes)
+--
+-- @param network_conf a table providing with settings dedicated for the
+-- network. Available fields includes:
+--
+-- * `network`: a `nerv.Layer` instance describing the structure of the network
+-- to be compiled
+-- * `clip`: a `number` value indicating the cliping threshold (i.e. preserve
+-- the values within [-clip, +clip])
+-- * `nn_act_default`: a `number` value indicating the value used for filling
+-- "holes" in activation values of a batch matrix (0 by default)
+
function network:__init(id, global_conf, network_conf)
self.id = id
self.network = network_conf.network
@@ -150,6 +188,11 @@ function network:compile(layer)
return socket
end
+--- Initialize the network for training.
+-- To be called before all the epochs, will resolve the structure of the
+-- network and allocate the memory for storing temporary values
+-- @param batch_size The size of a batch matrix
+-- @param chunk_size The size of a BPTT chunk
function network:init(batch_size, chunk_size)
self.batch_size = batch_size
self.chunk_size = chunk_size
@@ -167,6 +210,8 @@ function network:init(batch_size, chunk_size)
end
end
+--- Initialize the internal state of the network for the new epoch.
+-- To be called before each new epoch
function network:epoch_init()
self.timestamp = 0
for i = 1, #self.layers do
@@ -457,15 +502,29 @@ function network:set_err_output(err_output)
end
end
---[[
- [info] is a table that contains information of current mini-batch. These fields must be contained:
- [input], [output] : matrix array which stores the network input and output
- [seq_length] : a table contains the length of every sequences
- [new_seq]: a table contains the batch number of new sequences
- [do_train]: a bool value indicates do train or not
- if [do_train] is true, these fileds also must be contained:
- [err_input], [err_output] : matrix array which stores the network err_input and err_output
---]]
+--- Initialize the internal state of the network for the new mini-batch (a BPTT chunk).
+-- To be called before each propagation/back-propagation
+-- @param info a table containing information needed for the current mini-batch computation. The following fields must be supplied:
+--
+-- * `input`: an array containing `chunk_size` number of row-major batch
+-- matrices with `batch_size` rows
+-- * `output`: similar to `input`, but the matrices have different number of
+-- columns (depending on the width of the output, which is typically 1 for
+-- criteria, i.e. single column indicating the error), used to hold the output of the network
+-- * `seq_length` : a table containing the length (number of frames) of each sequence (utterance)
+-- * `new_seq`: a table containing the indices of batch matrix rows that are the
+-- first frames of a sequence
+-- * `do_train`: a bool value indicating whether to update the network
+--
+-- If `do_train` is true, two additional fields are required:
+--
+-- * `err_input`: an array with the same structure as `output` but containg the initial
+-- values for computing errors in back-propagation (when the width of the
+-- output is 1, `gconf.mask` is typically used here to ignore the invalid
+-- values produced by "holes" in the mini-batch).
+-- * `err_output`: an array with the same structure as `input`. Although we
+-- are mostly not interested in its values, just allocate this to unify
+-- the computation and ease the implementation
function network:mini_batch_init(info)
self.info = info
self:set_input(self.info.input)
@@ -573,6 +632,7 @@ function network:mini_batch_init(info)
end
end
+--- Perform a propagation.
function network:propagate()
for i = 1, #self.queue do
local t, id = self.queue[i].chunk, self.queue[i].id
@@ -590,6 +650,7 @@ function network:propagate()
end
end
+--- Perform a backward propagation to calculate gradients used for update.
function network:back_propagate()
for i = #self.queue, 1, -1 do
local t, id = self.queue[i].chunk, self.queue[i].id
@@ -614,6 +675,7 @@ function network:back_propagate()
end
end
+--- Update the parameters bound to each layer.
function network:update()
for i = 1, #self.layers do
self.layers[i]:update()