-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memristive network with memory workflow #2
base: master
Are you sure you want to change the base?
Conversation
@@ -348,7 +348,7 @@ def solveVi(self, Ve, Vgr=None, G=None, **kwargs): | |||
# inverse matrix A_II | |||
A_II = A[np.ix_(self._I, self._I)] | |||
# print(matrix_rank(A_II, hermitian=check_symmetric(A_II))) | |||
A_II_inv = inv(A_II) | |||
A_II_inv = pinv(A_II) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was getting errors from trying to invert a singular matrix (maybe multiple rows of all zeroes?). So I switched to the pseudoinverse to avoid this problem.
conn2res/reservoir.py
Outdated
V = np.zeros((len(Vi), self._n_nodes)) | ||
V[:, self._I] = np.asarray(Vi) | ||
V[:, self._E] = Vext | ||
return V |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EchoStateNetwork
returns a matrix that is size (n_times, n_nodes), while MemristiveReservoir
was returning (n_times, n_internal_nodes). This messes up the indexing for extracting readout nodes, for example, because those indexes were created relative to all nodes that exist, not just internal nodes.
self._Ga = mask(self, np.divide(self.Woff, self.NMSS, | ||
where=self.NMSS != 0)) # constant | ||
self._Gb = mask(self, np.divide(self.Won, self.NMSS, | ||
where=self.NMSS != 0)) # constant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was getting some divide by zero errors and infinites in the resulting matrices because of this. I added a condition to avoid dividing by zero here, and in some other places.
@@ -15,7 +15,8 @@ | |||
|
|||
from . import iodata, reservoir, coding | |||
|
|||
def memory_capacity(conn, input_nodes, output_nodes, readout_modules=None, | |||
|
|||
def memory_capacity(conn, input_nodes, output_nodes, rsn_mapping=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this to take in the raw mappings and index with the output nodes later. This is because output nodes will sometimes get adjusted in this method when randomly selecting the ground node.
readout_nodes = np.setdiff1d(readout_nodes, gr_nodes) | ||
|
||
# second dimension should be along the input nodes | ||
x = np.tile(x, (1, len(input_nodes))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MemristiveReservoir.simulate
expects an inputs that is size (n_examples, n_external_nodes). This is different than EchoStateNetwork
which only requires the input size second dimension align with the first dimension of w_in
.
|
||
# simulate reservoir states; select only output nodes | ||
rs = network.simulate(ext_input=x)[:,output_nodes] | ||
rs = network.simulate(x)[:, output_nodes] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In MSSNetwork
, this input is called Vext
not ext_input
. I'm not sure if it's better to just avoid explicitly passing a parameter-value pair, or to change the API of MSSNetwork
to be the same as EchoStateNetwork
. I chose the former for now. Also, there's no ability to choose 'forward' or 'backward' right now. Let me know if this is important to add.
Primary change is adjusting the memory workflow structure to work with the parametrization
resname='MSSNetwork'
. To achieve this, some small changes were made to thememory_capacity
API and the return type ofMemristiveReservoir.simulate
was slightly altered to align more closely withEchoStateNetwork.simulate
. Also, some small stability changes inMSSNetwork
were made.Sample output from running the workflow is shown below.