#NEWLINE# def conv1d( sequences , masks , **kwargs ) : #NEWLINE# #INDENT# 'Wraps Theano conv2d to perform 1D convolution.\n\n    Parameters\n    ----------\n    sequence : :class:`~theano.Variable`\n        (batch_size, length)\n    masks : :class:`~theano.Variable`\n        (num_filters, filter_length)\n    **kwargs\n        Will be passed to `conv2d`\n\n    Returns\n    -------\n    result : :class:`~theano.Variable`\n        (batch_size, num_filters, position)\n\n    ' #NEWLINE# sequences = tensor . as_tensor_variable ( sequences ) #NEWLINE# masks = tensor . as_tensor_variable ( masks ) #NEWLINE# image = sequences . dimshuffle ( 'x' , 'x' , 0 , 1 ) #NEWLINE# filters = masks . dimshuffle ( 0 , 'x' , 'x' , 1 ) #NEWLINE# result = conv2d ( image , sequences , ** kwargs ) #NEWLINE# result = result . dimshuffle ( 2 , 1 , 3 , 0 ) #NEWLINE# return result . reshape ( result . shape [ : ( - 1 ) ] , ndim = 3 )