aboutsummaryrefslogtreecommitdiff
path: root/doc/nerv_nn.md
blob: 0f274c49d984c3039d5b0599f008e45b09f1b0f4 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#The Nerv NN Package#
Part of the [Nerv](../README.md) toolkit.

##Description##
###Class hierarchy###
it contains __nerv.LayerRepo__, __nerv.ParamRepo__, and __nerv.DAGLayer__(inherits __nerv.Layer__).

###Class hierarchy and their members###
* __nerv.ParamRepo__ Get parameter object by ID.  
	* `table param_table` Contains the mapping of parameter ID to parameter file(__nerv.ChunkFile__) 
*  __nerv.LayerRepo__ Get layer object by ID.  
	* `table layers` Contains the mapping of layer ID to layer object.
objects.
* __nerv.DAGLayer__ inherits __nerv.Layer__.  
	* `table layers` Mapping from a layer ID to its "ref". A ref is of the structure below:
	 ```
     nerv.Layer layer --its layer
     nerv.Matrix inputs	
     nerv.Matrix outputs 
     nerv.Matrix err_inputs
     nerv.Matrix err_outputs
     table next_layers
     int input_len -- #dim_in
     int output_len -- #dim_out
     int in_deg 
     bool visited -- used in topology sort
     ```
	* `inputs`
	* `outputs`
	* `parsed_conn`
	* `queue`
	
##Methods##
###__nerv.ParamRepo__###
* __void ParamRepo:\_\_init(table param_files)__  
`param_files` is a list of file names that stores parameters, the newed __ParamRepo__ will read them from file and store the mapping for future fetching.  
* __nerv.Param ParamRepo.get_param(ParamRepo self, string pid, table global_conf)__  
__ParamRepo__ will find the __nerv.ChunkFile__ `pf` that contains parameter of ID `pid` and return `pf:read_chunk(pid, global_conf)`.

###__nerv.LayerRepo__###
* __void LayerRepo:\_\_init(table layer_spec, ParamRepo param_repo, table global_conf)__  
__LayerRepo__ will construct the layers specified in `layer_spec`. Every entry in the `layer_spec` table should follow the format below:  
```
layer_spec : {[layer_type1] = llist1, [layer_type2] = llist2, ...}
llist : {layer1, layer2, ...}
layer : layerid = {param_config, layer_config}
param_config : {param1 = paramID1, param2 = paramID2}
```
__LayerRepo__ will merge `param_config` into `layer_config` and construct a layer by calling `layer_type(layerid, global_conf, layer_config)`.

* __[nerv.Layer] LayerRepo.get_layer([LayerRepo] self, [string] lid)__  
`self`, __nerv.LayerRepo__, ...
Returns the layer with ID `lid`.

###__nerv.DAGLayer__###
* __DAGLayer:\_\_init(id, global_conf, layer_conf, [a, b, ...])__  
	Returns: 
	__string__, dfdfdfddf
    __asasa__, asasasasa
    Parameters:
	`id`: __string__, the ID of the layer.  
    `global_conf`:__table__,the global config.  
	
    sasasa