def unRollImagesForConv(self,index):
'''?????index?????
?? ?width*?height, ?????*?channel? ????size??????
'''
i = index
old_images = self.last_layer.images
m,old_channel,old_height,old_width = old_images.shape
newData = []
#Process unroll the data
for h in range(0,old_height-self.squareSize+1,self.stride):
for w in range(0,old_width-self.squareSize+1,self.stride):
tmp = []
for c in range(old_channel):
tmp.append(old_images[i,c,h:h+self.squareSize,w:w+self.squareSize].reshape(1,self.squareSize**2))
#h,w?????,??????????,??old_channel * squaireSize?????
tmp = np.array(tmp).reshape(1,self.squareSize**2*old_channel)
#?????reshape,????????,????newData
newData.append(tmp)
#??????????????????,?????????
newData = np.array(newData).reshape(self.width*self.height,self.squareSize**2*old_channel)
return newData
评论列表
文章目录