예제 #1
0
# 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
net.train(p);

# test readout
print "NRMSE readout: %f" % (util.nrmse(net.W_out.dot(net.all_train_args), net.all_train_outs));
print "mean NEMSE W: %f" % util.nrmse(net.W.dot(net.all_train_old_args), net.W_targets);

y=net.W_out.dot(net.all_train_args)
print y.shape
print net.all_train_outs.shape

pplot.figure(1);
pplot.plot(xrange(1000), p[0][0,500:1500]);
pplot.plot(xrange(1000), y[0,0:1000]);
pplot.title("Redout")
pplot.show();
예제 #2
0
# 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
net.train(p);

# test readout
print "NRMSE readout: %f" % (util.nrmse(net.W_out.dot(net.all_train_args), net.all_train_outs));
print "mean NEMSE W: %f" % util.nrmse(net.W.dot(net.all_train_old_args), net.W_targets);

y=net.W_out.dot(net.all_train_args)
print y.shape
print net.all_train_outs.shape

pplot.figure(1);
pplot.plot(xrange(1000), p[0][0,500:1500]);
pplot.plot(xrange(1000), y[0,0:1000]);
pplot.title("Redout")
pplot.show();
예제 #3
0
# 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
net.train(p)

# test readout
print "NRMSE readout: %f" % (util.nrmse(net.W_out.dot(net.all_train_args),
                                        net.all_train_outs))
print "mean NEMSE W: %f" % util.nrmse(net.W.dot(net.all_train_old_args),
                                      net.W_targets)

y = net.W_out.dot(net.all_train_args)
print y.shape
print net.all_train_outs.shape

pplot.figure(1)
pplot.plot(xrange(1000), p[0][0, 500:1500])
pplot.plot(xrange(1000), y[0, 0:1000])
pplot.title("Redout")
예제 #4
0
    
  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)):
  
  # get activation
  
  x=np.zeros((net.num_neuron,1));
  for j in xrange(200):
    x=np.tanh(net.W_star.dot(x)+net.W_in.dot(img[None].T)+net.W_bias);
예제 #5
0
        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)):

    # get activation

    x = np.zeros((net.num_neuron, 1))
    for j in xrange(200):
        x = np.tanh(