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:40] – Added a headline zenkemanual:wmat [2014/12/02 10:03] (current) – Fixes bug in example zenke
Line 25: 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.1383320446.txt.gz · Last modified: 2013/11/01 15:40 by zenke