#NEWLINE# def __init__( self , pos , mbs , g , nifm , ifmshape_nopad , fshape , nofm , strides , dtypeu , padding = 0 ) : #NEWLINE# #INDENT# assert ( g == identity ) #NEWLINE# ( self . ifmheight , self . ifmwidth ) = ifmshape_nopad #NEWLINE# self . ifmshape_nopad = ifmshape_nopad #NEWLINE# self . padding = padding #NEWLINE# self . ifmshape = ( ( self . ifmheight + ( 2 * padding ) ) , ( self . ifmwidth + ( 2 * padding ) ) ) #NEWLINE# self . fshape = fshape #NEWLINE# self . stride = strides #NEWLINE# ( self . fheight , self . fwidth ) = fshape #NEWLINE# self . ofmheight = ( ( ( self . ifmshape [ 0 ] - self . fheight ) / strides ) + 1 ) #NEWLINE# self . ofmwidth = ( ( ( self . ifmshape [ 1 ] - self . fwidth ) / strides ) + 1 ) #NEWLINE# ofmshape = ( self . ofmheight , self . ofmwidth ) #NEWLINE# self . ifmsize = ( self . ifmshape [ 0 ] * self . ifmshape [ 1 ] ) #NEWLINE# self . ifmsize_nopad = ( self . ifmshape_nopad [ 0 ] * self . ifmshape_nopad [ 1 ] ) #NEWLINE# self . ofmsize = ( self . ofmheight * self . ofmwidth ) #NEWLINE# self . nout = ( self . ofmsize * nofm ) #NEWLINE# self . nifm = nifm #NEWLINE# self . nofm = nofm #NEWLINE# self . fsize = ( ( nifm * self . fheight ) * self . fwidth ) #NEWLINE# self . weights = np . zeros ( ( nofm , self . fsize ) , dtype = dtypeu ) #NEWLINE# self . g = g #NEWLINE# self . gprime = get_prime ( g ) #NEWLINE# self . z = np . zeros ( ( mbs , self . nout ) , dtype = dtypeu ) #NEWLINE# self . y = np . zeros ( ( mbs , self . nout ) , dtype = dtypeu ) #NEWLINE# ofmstarts = np . array ( range ( 0 , ( self . ofmsize * nofm ) , self . ofmsize ) ) #NEWLINE# self . ofmlocs = np . zeros ( ( g . ofmsize , nofm ) , dtype = 'i32' ) #NEWLINE# for dst in range ( self . ofmsize ) : #NEWLINE# #INDENT# self . ofmlocs [ dst , : ] = ( ofmstarts + dst ) #NEWLINE# #UNINDENT# self . links = [ ] #NEWLINE# self . makelinks ( nifm , self . ifmsize , self . ifmshape , ofmshape , fshape , strides ) #NEWLINE# self . updates = np . zeros ( self . weights . shape , dtype = dtypeu ) #NEWLINE# self . updateshards = np . zeros ( ( ( self . fheight * self . fwidth ) , nofm , self . fsize ) , dtype = dtypeu ) #NEWLINE# self . updatebuf = np . zeros ( ( nofm , self . fsize ) , dtype = dtypeu ) . copy ( ) #NEWLINE# self . pos = pos #NEWLINE# if ( self . pos > 0 ) : #NEWLINE# #INDENT# self . bpropbuf = np . zeros ( ( mbs , self . fsize ) , dtype = dtypeu ) #NEWLINE# self . berror = np . zeros ( ( mbs , ( self . ifmsize * nifm ) ) , dtype = dtypeu ) #NEWLINE# self . berrorshards = np . zeros ( ( ( self . fheight * self . fwidth ) , mbs , ( self . ifmsize * nifm ) ) , dtype = dtypeu )