def next(self,input): # not preserve(net.initial_state) t = self.net(input) t.shape = (1,self.rsize) self.last_state = t #saving state self.net.initial_state = self.last_state #restore state esnout = self.last_state.copy() esnout = self.Out.process(esnout) #compute esnout esnout = aux.normalize(esnout) return esnout
def spectral_clustering_sym(S, k): n, _ = S.shape L = aux.laplacian(S) D = np.diag(np.sum(S, axis=1)) D_half = np.sqrt(D) D_minus_half = np.diag(1 / np.diag(D_half)) w, V = np.linalg.eigh(D_minus_half.dot(L).dot(D_minus_half)) index = np.argsort(w) U = _stack_vec(V, k, index) for row in U: row = aux.normalize(row) print(U) _, label = cluster.vq.kmeans2(U, k) return label.reshape((-1, 1))
def next(self,input, i = None): # not preserve(net.initial_state) t = self.net(input) t.shape = (1,self.rsize) if i == None: i = self.index.label(t)[0] if (i >= len(self.stm)): i = -1 self.last_state = t #saving state self.net.initial_state = self.last_state #restore state esnout = self.last_state.copy() esnout = self.stm[i].process(esnout) esnout = aux.normalize(esnout) return esnout