brianthelion

dotconv.py

Oct 4th, 2011
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. def dotconv( imdesc,fdesc ) :
  2.  
  3.     assert imdesc.ndim == 3 and fdesc.ndim == 3
  4.     iw,ih,id = imdesc.shape
  5.     fw,fh,fd = fdesc.shape
  6.    
  7.     assert id == fd
  8.     assert fw < iw and fh < ih
  9.    
  10.     ow,oh = iw-fw+1,ih-fh+1
  11.     output = numpy.zeros( [ow,oh] )
  12.    
  13.     for x in xrange(ow) :
  14.         for y in xrange(oh) :
  15.            
  16.             window = imdesc[x:x+fw,y:y+fh,:]
  17.             output[x,y] = dot_product( window.flatten(),fdesc.flatten() )
  18.    
  19.     return output
  20.  
Advertisement
Add Comment
Please, Sign In to add comment