python - Unclear Array shape -


i creating ann controller identification model having 3 hidden layers , controller model having 2.the method indirect control. below code forward propagation. input sin input , pass whole array in batch controller model. identification model need pass output of controller model element wise.

x:input(shape = 500,1) u:output controller model(shape = 500,1) y:final output identification model(shape = 500,1) there 30 nodes in each hidden layer 

forward algo controller:-

def forwardi(self, x):     u = np.zeros(x.shape)     y =np.zeros(x.shape)     self.n.a2 = []     self.n.a3 = []     self.n.z2 = []     self.n.z3 = []     self.n.z4 = []     in xrange (1,len(x)):             self.q=np.append(x[i],u[i-1],axis=0)         self.q=np.append(self.q,y[i-1],axis=0).reshape(3,1)         self.z2 = np.dot(self.q.t,self.w1)         self.a2 = self.sigmoid(self.z2).reshape(1,30)         self.z3 = np.dot(self.a2, self.w2)         self.a3 = self.sigmoid(self.z3).reshape(1,1)         u[i]=self.a3         y[i] =      self.n.forward(u[i],self.n.a2,self.n.a3,self.n.z2,self.n.z3,self.n.z4)                 self.n.a2.append(self.n.a2)     self.n.a3.append(self.n.a2)     self.n.z2.append(self.n.a2)     self.n.z3.append(self.n.a2)     self.n.z4.append(self.n.a2)     self.n.a2 = np.asarray(self.n.a2).reshape(500,30)     self.n.a3 = np.asarray(self.n.a3).reshape(500,30)     self.n.z2 = np.asarray(self.n.z2).reshape(500,30)     self.n.z3 = np.asarray(self.n.z3).reshape(500,30)     self.n.z4 = np.asarray(self.n.z4).reshape(500,1)     return u,y   

and forward algo identification:-

def forward(self,x,a2,a3,z2,z3,z4):     self.z2 = np.dot(x,self.w1).reshape(30,1)     z2.append(self.z2)     self.a2 = self.sigmoid(self.z2)     a2.append(self.a2)             self.z3 = np.dot(self.a2.t,self.w2)     z3.append(self.z3)             self.a3 = self.sigmoid(self.z3)     a3.append(self.a3)     self.z4 = np.dot(self.a3,self.w3)             z4.append(self.z4)             self.yhat = self.sigmoid(self.z4)     return self.yhat     

now can explain me why following occurs:- nni object identification class.

w = np.asarray(nni.a3) w.shape out[179]: (500l,) w[1].shape out[180]: (1l, 30l) 


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -