#NEWLINE# def make_sparse_random_conv2D( num_nonzero , input_space , output_space , kernel_shape , batch_size , subsample = ( 1 , 1 ) , border_mode = 'valid' , message = '' , rng = None ) : #NEWLINE# #INDENT# '\n    .. todo::\n\n        WRITEME properly\n\n    Creates a Cudnn2D with random kernels, where the randomly initialized\n    values are sparse\n\n    Parameters\n    ----------\n    num_nonzero : TODO\n    input_space : TODO\n    output_space : TODO\n    kernel_shape : TODO\n    batch_size : TODO\n    subsample : TODO, optional\n    border_mode : TODO, optional\n    message : TODO, optional\n    rng : TODO, optional\n\n    ' #NEWLINE# raise AssertionError ( "TODO: I think this is a bug--num_nonzero determines the total number of nonzero elements in the whole kernel stack, not the number of non-zero elements per kernel. Investigate what it's meant to do." ) #NEWLINE# rng = make_np_rng ( rng , default_sparse_seed , which_method = [ 'randn' , 'randint' ] ) #NEWLINE# W = np . zeros ( ( output_space . num_channels , input_space . num_channels , kernel_shape [ 0 ] , kernel_shape [ 1 ] ) ) #NEWLINE# def random_coord( ) : #NEWLINE# #INDENT# return [ rng . randint ( dim ) for dim in W . shape ] #NEWLINE# #UNINDENT# for i in range ( num_nonzero ) : #NEWLINE# #INDENT# ( o , ch , r , c ) = random_coord ( ) #NEWLINE# while ( W [ ( o , ch , r , c ) ] != 0 ) : #NEWLINE# #INDENT# ( o , ch , r , c ) = random_coord ( ) #NEWLINE# #UNINDENT# W [ ( o , ch , r , c ) ] = rng . randn ( ) #NEWLINE# #UNINDENT# W = sharedX ( W ) #NEWLINE# return Cudnn2D ( filters = W , batch_size = batch_size , input_space = input_space , output_axes = output_space . axes , subsample = subsample , border_mode = border_mode , filters_shape = W . get_value ( borrow = True ) . shape , message = message )