def assert_conv_shape(shape):
 out_shape = []
 for (i, n) in enumerate(shape):
  try:
   const_n = get_scalar_constant_value(n)
   if (i < 2):
    if (const_n < 0):
     raise ValueError(('The convolution would produce an invalid shape (dim[%d]: %d < 0).' % (i, const_n)))
   elif (const_n <= 0):
    raise ValueError(('The convolution would produce an invalid shape (dim[%d]: %d <= 0).' % (i, const_n)))
   out_shape.append(n)
  except NotScalarConstantError:
   if (i < 2):
    assert_shp = Assert(('The convolution would produce an invalid shape (dim[%d] < 0).' % i))
    out_shape.append(assert_shp(n, theano.tensor.ge(n, 0)))
   else:
    assert_shp = Assert(('The convolution would produce an invalid shape (dim[%d] <= 0).' % i))
    out_shape.append(assert_shp(n, theano.tensor.gt(n, 0)))
 return tuple(out_shape)

def assert_conv_shape ( shape ) : out_shape = [ ] for ( i , n ) in enumerate ( shape ) : try : const_n = get_scalar_constant_value ( n ) if ( i < 2 ) : if ( const_n < 0 ) : raise ValueError ( ( 'The convolution would produce an invalid shape (dim[%d]: %d < 0).' % ( i , const_n ) ) ) elif ( const_n <= 0 ) : raise ValueError ( ( 'The convolution would produce an invalid shape (dim[%d]: %d <= 0).' % ( i , const_n ) ) ) out_shape . append ( n ) except NotScalarConstantError : if ( i < 2 ) : assert_shp = Assert ( ( 'The convolution would produce an invalid shape (dim[%d] < 0).' % i ) ) out_shape . append ( assert_shp ( n , theano . tensor . ge ( n , 0 ) ) ) else : assert_shp = Assert ( ( 'The convolution would produce an invalid shape (dim[%d] <= 0).' % i ) ) out_shape . append ( assert_shp ( n , theano . tensor . gt ( n , 0 ) ) ) return tuple ( out_shape )
this function adds assert nodes that check if shape is a valid convolution shape .