def buildSharedCrossedNetwork():
 N = FeedForwardNetwork('shared-crossed')
 h = 1
 a = LinearLayer(2, name='a')
 b = LinearLayer(h, name='b')
 c = LinearLayer(h, name='c')
 d = LinearLayer(2, name='d')
 N.addInputModule(a)
 N.addModule(b)
 N.addModule(c)
 N.addOutputModule(d)
 m1 = MotherConnection(h)
 m1.params[:] = scipy.array((1,))
 m2 = MotherConnection(h)
 m2.params[:] = scipy.array((2,))
 N.addConnection(SharedFullConnection(m1, a, b, inSliceTo=1))
 N.addConnection(SharedFullConnection(m1, a, c, inSliceFrom=1))
 N.addConnection(SharedFullConnection(m2, b, d, outSliceFrom=1))
 N.addConnection(SharedFullConnection(m2, c, d, outSliceTo=1))
 N.sortModules()
 return N

def buildSharedCrossedNetwork ( ) : N = FeedForwardNetwork ( 'shared-crossed' ) h = 1 a = LinearLayer ( 2 , name = 'a' ) b = LinearLayer ( h , name = 'b' ) c = LinearLayer ( h , name = 'c' ) d = LinearLayer ( 2 , name = 'd' ) N . addInputModule ( a ) N . addModule ( b ) N . addModule ( c ) N . addOutputModule ( d ) m1 = MotherConnection ( h ) m1 . params [ : ] = scipy . array ( ( 1 , ) ) m2 = MotherConnection ( h ) m2 . params [ : ] = scipy . array ( ( 2 , ) ) N . addConnection ( SharedFullConnection ( m1 , a , b , inSliceTo = 1 ) ) N . addConnection ( SharedFullConnection ( m1 , a , c , inSliceFrom = 1 ) ) N . addConnection ( SharedFullConnection ( m2 , b , d , outSliceFrom = 1 ) ) N . addConnection ( SharedFullConnection ( m2 , c , d , outSliceTo = 1 ) ) N . sortModules ( ) return N
build a network with shared connections .