python - error in printing a N-Dimensional Numpy Matrix -
im having problems printing numpy 6-dimentional matrix. import numpy np qmatrix = np.zeros((((((5,6,10,12,10,8))))))
i used , after populating matrix tried print matrix using
print (qmatrix)
then comes bunch of zeros. when search value in matrix gives me correct value.
print (qmatrix[1][2][4][2][5][7]) >>> 12.45
do have convert matrix in sort before printing matrix here full code used
class q_matrix_base(object): def __init__(self, leadvehspd,leadvehipos,estdisctime,folvehspeed,folvehpos,rgt): self.leadvehspd = leadvehspd self.leadvehipos = leadvehipos self.estdisctime = estdisctime self.folvehpos = folvehpos self.folvehspeed = folvehspeed self.rgt = rgt # initialize matrix , fill zeroes self.qmatrix = np.zeros((((((leadvehspd,leadvehipos,estdisctime,folvehspeed,folvehpos,rgt)))))) #self.qmatrix.fill(0) def setitem (self ,leadvehspd,leadvehipos,estdisctime,folvehspeed,folvehpos,rgt,reward): #assign values specific place self.qmatrix[leadvehspd,leadvehipos,estdisctime,folvehspeed,folvehpos,rgt] = reward def getitem (self,leadvehspd,leadvehipos,estdisctime,folvehspeed,folvehpos,rgt): #get value row , column return self.qmatrix[leadvehspd][leadvehipos][estdisctime][folvehspeed][folvehpos][rgt] def printmaa (self,lk): np.save('c:\\example\\matrixsecondstage2.npy', self.qmatrix) return self.qmatrix def getposspeed (self,leadvehspd,leadvehipos,estdisctime,folvehpos,rgt): #to select specific row(i) in matrix return self.qmatrix[leadvehspd,leadvehipos,estdisctime,:,folvehpos,rgt]
Comments
Post a Comment