Auryn simulator

Simulator for spiking neural networks with synaptic plasticity

User Tools

Site Tools


manual:wmat

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
manual:wmat [2013/11/01 15:28] – Adds nota bene on indexing starting from 1 zenkemanual:wmat [2014/12/02 10:03] (current) – Fixes bug in example zenke
Line 1: Line 1:
 ''wmat'' files are used to store weight matrices in the MatrixMarket format, which can be exchanged easily with MATLAB and other software ([[http://en.wikipedia.org/wiki/Matrix_Market_exchange_formats]]). Since in many cases connection matrices are sparse, Auryn uses the ''coordinate real'' format, which needs to be kept in row major order, since it directly maps Auryn's internal sparse matrix format [[SimpleMatrix]]. ''wmat'' files are used to store weight matrices in the MatrixMarket format, which can be exchanged easily with MATLAB and other software ([[http://en.wikipedia.org/wiki/Matrix_Market_exchange_formats]]). Since in many cases connection matrices are sparse, Auryn uses the ''coordinate real'' format, which needs to be kept in row major order, since it directly maps Auryn's internal sparse matrix format [[SimpleMatrix]].
  
 +See also [[SparseConnection]].
 +
 +====== File structure ======
  
 The header of a typical weight matrix looks the following: The header of a typical weight matrix looks the following:
Line 22: Line 25:
 **Nota bene:** Cells in the wmat file are  indexed starting from 1 (unlike everywhere else in Auryn, where we adapt the C convention and start numbering arrays with 0). **Nota bene:** Cells in the wmat file are  indexed starting from 1 (unlike everywhere else in Auryn, where we adapt the C convention and start numbering arrays with 0).
  
 +
 +===== Loading Matrix Market files in Python for analysis =====
 +
 +In Python Auryn's wmat files can be loaded or saved using existing SciPy functionality ([[http://docs.scipy.org/doc/scipy/reference/io.html]]). To load the output file ''output.wmat'' in Python it is sufficient to invoke the following code:
 +
 +<code python>
 +from scipy.sparse import *
 +from scipy.io import mmread
 +
 +A = mmread('output.wmat')
 +</code>
 +''A'' now contains the Auryn output weight matrix ''output.wmat'' as a sparse matrix for further processing.
 +
 +
 +
 +===== Saving Matrix Market files in Python =====
 +
 +Likewise, a structured matrix can be prepared in Python and then be loaded in Auryn. To do so, use code along the lines of the following snipped:
 +<code python>
 +from scipy.sparse import *
 +from scipy.io import mmwrite
 +
 +# code which generates the matrix A
 +
 +sw = csr_matrix(A) # ensures row major format in COO output
 +mmwrite('save.wmat',sw)
 +</code>
 +
 +The additional conversion step to a csr_matrix is necessary to ensure the correct ordering of entries in the text file. If this step is omitted, Auryn might not be able to parse the sparse matrix and will throw a runtime exception.
 +
 +**Note** that in many cases SciPy will append the file extension ''mtx'' to the output file which will require you to rename it to wmat afterwards. 
manual/wmat.1383319725.txt.gz · Last modified: 2013/11/01 15:28 (external edit)