def __init__(self, architecture): self.architecture = architecture self.ae = {} for i in range(len(architecture) - 1): self.ae.setdefault(i) self.ae[i] = NNC([ self.architecture[i], self.architecture[i + 1], self.architecture[i] ]) pass
print q.ae[0].W[0].shape print q.ae[0].W[0][1:,:].shape x_length = 10; y_length = 10 fig = plt.figure() for i in range(x_length * y_length): im = q.ae[0].W[0][1:,:][:,i].reshape(28, 28) plotwindow = fig.add_subplot(y_length, x_length, i + 1) plt.imshow(im , cmap='gray') plt.show() architect = [784,200,10]; option ={} a=NNC(architect,option) groundTruth=a.handle_y_4classify(trian_labels); #start=clock() #for i in range(4): # a.test() #finish=clock() #print (finish-start)/10000 a.learningRate=0.4 a.weightPenaltyL2 = 0.0001 opts={'batchsize':100,'numepochs':4} a.output='softmax' a.activation ='tanh' a.W[0]=q.ae[0].W[0] a.train(train_images,groundTruth,opts) qq=a.nnpred(test_images) print qq