from conceptors.net import ConceptorNetwork; from conceptors.dataset import read_jpv_data; from conceptors.dataset import normalize_jap_data; from conceptors.dataset import transform_jap_data; train_inputs, train_outputs, test_inputs, test_outputs=read_jpv_data("/home/arlmaster/workspace/conceptors/conceptors/data/ae.train", "/home/arlmaster/workspace/conceptors/conceptors/data/ae.test"); train_data, shifts, scales=normalize_jap_data(train_inputs); test_data=transform_jap_data(test_inputs, shifts, scales); # Create conceptor network net=ConceptorNetwork(2, 200); # Prepare testing data p1=np.asarray(xrange(2000)); p1=np.sin(2*np.pi*p1/np.sqrt(75)); p2=np.asarray(xrange(2000)); #p2=0.5*np.sin(2*np.pi*p2/np.sqrt(20))+np.sin(2*np.pi*p2/np.sqrt(40)); p2=np.sin(2*np.pi*p2/np.sqrt(40)); ps=np.vstack((p1[None], p2[None])); p=[]; p.append(ps); #p.append(p1[None]); #p.append(p2[None]); # training
if not x_temp.size: x_temp=Xtrain[idx,1:]; else: x_temp=np.vstack((x_temp, Xtrain[idx,1:])); idx+=1; print "Class %i is generated" % i; X.append(x_temp.T); n_in=X[0].shape[0]; num_neuron=500; net=ConceptorNetwork(num_in=n_in, num_neuron=num_neuron, washout_length=200, learn_length=700); print "the network is created"; net.train(X); print "the network is trained"; conceptors=net.Cs[0]; img=Xtest[1]; pos_evidence=np.zeros((1, len(conceptors))); for i in xrange(len(conceptors)):
from conceptors.net import ConceptorNetwork; from conceptors.dataset import read_jpv_data; from conceptors.dataset import normalize_jap_data; from conceptors.dataset import transform_jap_data; #train_inputs, train_outputs, test_inputs, test_outputs=read_jpv_data("/home/arlmaster/workspace/conceptors/conceptors/data/ae.train", # "/home/arlmaster/workspace/conceptors/conceptors/data/ae.test"); #train_data, shifts, scales=normalize_jap_data(train_inputs); #test_data=transform_jap_data(test_inputs, shifts, scales); # Create conceptor network net=ConceptorNetwork(2, 200); # Prepare testing data p1=np.asarray(xrange(2000)); p1=np.sin(2*np.pi*p1/np.sqrt(75)); p2=np.asarray(xrange(2000)); #p2=0.5*np.sin(2*np.pi*p2/np.sqrt(20))+np.sin(2*np.pi*p2/np.sqrt(40)); p2=np.sin(2*np.pi*p2/np.sqrt(40)); ps=np.vstack((p1[None], p2[None])); p=[]; p.append(ps); #p.append(p1[None]); #p.append(p2[None]); # training
while idx != num_train and Xtrain[idx, 0] == i: if not x_temp.size: x_temp = Xtrain[idx, 1:] else: x_temp = np.vstack((x_temp, Xtrain[idx, 1:])) idx += 1 print "Class %i is generated" % i X.append(x_temp.T) n_in = X[0].shape[0] num_neuron = 500 net = ConceptorNetwork(num_in=n_in, num_neuron=num_neuron, washout_length=200, learn_length=700) print "the network is created" net.train(X) print "the network is trained" conceptors = net.Cs[0] img = Xtest[1] pos_evidence = np.zeros((1, len(conceptors))) for i in xrange(len(conceptors)):