Module Expr Str Assign NameStore Str Assign NameStore Str Assign NameStore ListLoad Str Str Str Assign NameStore Str Assign NameStore Str Assign NameStore Str Import alias Import alias Import alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias Import alias ImportFrom alias FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str If CompareNotEq SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num body Raise Call NameLoad Str Assert CompareGt SubscriptLoad NameLoad Index Num Num Assign TupleStore NameStore NameStore NameStore NameStore AttributeLoad NameLoad attr Assign TupleStore NameStore NameStore NameLoad If CompareIs NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr TupleLoad NameLoad BinOpDiv NameLoad NameLoad BinOpDiv NameLoad NameLoad NameLoad keyword AttributeLoad NameLoad attr Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Num Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Return Call NameLoad NameLoad NameLoad decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Num Num body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Num Assert CompareGt NameLoad Num NameLoad Expr Call AttributeLoad NameLoad attr Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return BoolOpAnd CompareEq Call NameLoad NameLoad Call NameLoad NameLoad CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return BinOpBitXor BinOpBitXor BinOpBitXor Call NameLoad Call NameLoad NameLoad Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return IfExp AttributeLoad AttributeLoad NameLoad attr attr ListLoad NameLoad AttributeLoad AttributeLoad NameLoad attr attr ListLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return ListLoad Str Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return IfExp AttributeLoad AttributeLoad NameLoad attr attr ListLoad NameLoad AttributeLoad AttributeLoad NameLoad attr attr ListLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return IfExp AttributeLoad AttributeLoad NameLoad attr attr ListLoad Str AttributeLoad AttributeLoad NameLoad attr attr ListLoad Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return TupleLoad Num decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return BinOpMod Str Dict Str Str Str AttributeLoad AttributeLoad NameLoad attr attr NameLoad Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assert CompareEq AttributeLoad NameLoad attr Num Assert CompareEq AttributeLoad NameLoad attr Num Assign NameStore SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index Num Assign NameStore SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index Num Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore TupleLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore Call NameLoad keyword NameLoad Assign NameStore Call NameLoad Assign NameStore TupleLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore Call NameLoad keyword NameLoad Assign NameStore Call NameLoad Return Call NameLoad NameLoad ListLoad NameLoad NameLoad ListLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign TupleStore NameStore NameStore NameLoad Assign TupleStore NameStore NameStore NameLoad Assign NameStore SubscriptLoad NameLoad Index Str Assign NameStore Num If AttributeLoad NameLoad attr body Raise Call NameLoad orelse Assign NameStore Str Assign NameStore BinOpAdd Call AttributeLoad NameLoad attr Str Str AugAssignAdd NameStore Num Assign NameStore BinOpAdd Call AttributeLoad NameLoad attr Str Str AugAssignAdd NameStore Num Assign NameStore Str AugAssignAdd NameStore Num Assign NameStore Str AugAssignAdd NameStore Num Assign NameStore Str Assign NameStore BinOpMult Str NameLoad Assign NameStore BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore BinOpMod NameLoad Call NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign TupleStore NameStore NameStore NameLoad Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad Assign TupleStore NameStore NameStore NameLoad Assign NameStore Num Assign NameStore Num If Call NameLoad AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Num If Call NameLoad AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Num Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Return Call Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str If UnaryOpNot Call NameLoad body Raise Call NameLoad Str Return Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad decorator_list decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Num Assert BoolOpAnd CompareGt NameLoad Num CompareLtE NameLoad NameLoad TupleLoad NameLoad NameLoad Assert CompareGt NameLoad Num NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return BoolOpAnd CompareEq Call NameLoad NameLoad Call NameLoad NameLoad CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return BinOpBitXor BinOpBitXor BinOpBitXor Call NameLoad Call NameLoad NameLoad Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return IfExp AttributeLoad AttributeLoad NameLoad attr attr ListLoad NameLoad AttributeLoad AttributeLoad NameLoad attr attr ListLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return ListLoad Str Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return IfExp AttributeLoad AttributeLoad NameLoad attr attr ListLoad NameLoad AttributeLoad AttributeLoad NameLoad attr attr ListLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return IfExp AttributeLoad AttributeLoad NameLoad attr attr ListLoad Str AttributeLoad AttributeLoad NameLoad attr attr ListLoad Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return TupleLoad Num decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return BinOpMod Str Dict Str Str Str AttributeLoad AttributeLoad NameLoad attr attr NameLoad Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assert CompareEq AttributeLoad NameLoad attr Num Assert CompareEq AttributeLoad NameLoad attr Num Assert CompareEq AttributeLoad NameLoad attr Num Assert CompareEq AttributeLoad NameLoad attr Num TryExcept body Assign NameStore Call NameLoad Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index Num Assert CompareEq BinOpMod NameLoad Num Num handlers ExceptHandler type NameLoad body Pass Return Call NameLoad NameLoad ListLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad ListLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign TupleStore NameStore NameStore NameStore NameStore NameStore NameStore NameLoad Assign TupleStore NameStore NameStore NameLoad Assign NameStore SubscriptLoad NameLoad Index Str Assign NameStore Num If AttributeLoad NameLoad attr body Raise Call NameLoad orelse Assign NameStore Str Assign NameStore BinOpAdd Call AttributeLoad NameLoad attr Str Str AugAssignAdd NameStore Num Assign NameStore BinOpAdd Call AttributeLoad NameLoad attr Str Str AugAssignAdd NameStore Num Assign NameStore BinOpAdd Call AttributeLoad NameLoad attr Str Str AugAssignAdd NameStore Num Assign NameStore BinOpAdd Call AttributeLoad NameLoad attr Str Str AugAssignAdd NameStore Num Assign NameStore Str AugAssignAdd NameStore Num Assign NameStore Str AugAssignAdd NameStore Num Assign NameStore Str Assign NameStore BinOpMult Str NameLoad Assign NameStore BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore BinOpMod NameLoad Call NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Expr Str If UnaryOpNot Call NameLoad body Raise Call NameLoad Str Return Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad decorator_list decorator_list
N/A N/A 
A GPU implementation of probabilistic max-pooling, based on

"Convolutional Deep Belief Networks for Scalable
Unsupervised Learning of Hierarchical Representations"
Honglak Lee, Roger Grosse, Rajesh Ranganath, and Andrew Y. Ng
ICML 2009


This paper defines probabilistic max-pooling in the context
of a Convolutional Deep Belief Network (its energy function is
more like a DBM than a DBN but it is trained like a DBN). Here
we define probabilistic max pooling as a general layer for
use in an energy-based model regardless of how the rest of the
model is assembled.

The gpu code is written around Alex Krizhevsky's cuda-convnet
library
 N/A __authors__ Mehdi Mirza N/A __copyright__ Copyright 2010-2013, Universite de Montreal N/A __credits__ N/A Mehdi Mirza Ian Goodfellow David Warde-Farley N/A __license__ 3-clause BSD N/A __maintainer__ Mehdi Mirza N/A __email__ mirzamom@iro N/A warnings N/A theano N/A numpy theano tensor theano.gof Apply theano.sandbox.cuda CudaNdarrayType theano.sandbox.cuda.basic_ops as_cuda_ndarray_variable theano.sandbox.cuda.basic_ops gpu_contiguous theano.sandbox.cuda GpuOp theano.tensor get_scalar_constant_value NotScalarConstantError pylearn2.sandbox.cuda_convnet.base_acts UnimplementedError pylearn2.sandbox.cuda_convnet.convnet_compile convnet_available pylearn2.sandbox.cuda_convnet.convnet_compile cuda_convnet_loc pylearn2.sandbox.cuda_convnet.shared_code this_dir N/A pylearn2.sandbox.cuda_convnet.pthreads theano config prob_max_pool_c01b N/A N/A c01b pool_shape top_down N/A None N/A N/A 
    .. todo::

        WRITEME
     N/A N/A N/A pool_shape N/A 0 N/A pool_shape N/A 1 N/A N/A N/A UnimplementedError Non sqaure pool shapes are not supported yet N/A N/A N/A pool_shape N/A 0 0 N/A N/A ch zr zc batch_size N/A c01b shape N/A N/A r c pool_shape N/A N/A top_down None N/A N/A top_down N/A N/A tensor zeros N/A ch N/A zr r N/A zc c batch_size dtype N/A c01b dtype N/A op N/A ProbMaxPool N/A pool_shape N/A 0 N/A c01b N/A gpu_contiguous c01b N/A top_down N/A gpu_contiguous top_down N/A N/A op c01b top_down N/A ProbMaxPool N/A GpuOp N/A N/A 
    Probabilistic max pooling code on the GPU.
    The input are in the order (channel, image rows, image cols, batch)

    Works only on square images wiht square pooling shape
    and the grad works only when channel % 16 == 0.

    Parameters
    ----------
    ds : int
        defines the size of the pooling region in the x (equivalently, y)
        dimension. Squares of size (ds)2 get reduced to one value by this
        layer.  There are no restrictions on the value of this parameter. It's
        fine for a pooling square to fall off the boundary of the image. Named
        SizeX in Alex's code.
    stride : int
        defines the stride size between successive pooling squares. Setting
        this parameter smaller than sizeX produces overlapping pools. Setting
        it equal to sizeX gives the usual, non-overlapping pools. Values
        greater than sizeX are not allowed.
    start : int, optional
        tells the net where in the input image to start the pooling (in x,y
        coordinates). In principle, you can start anywhere you want. Setting
        this to a positive number will cause the net to discard some pixels at
        the top and at the left of the image. Setting this to a negative number
        will cause it to include pixels that don't exist (which is fine).
        start=0 is the usual setting.
    outputs : int, optional
        allows you to control how many output values in the x (equivalently, y)
        dimension this operation will produce. This parameter is analogous to
        the start parameter, in that it allows you to discard some portion of
        the image by setting it to a value small enough to leave part of the
        image uncovered. Setting it to zero instructs the net to produce as
        many outputs as is necessary to ensure that the whole image is covered.
        default 0
     __init__ N/A N/A self ds start outputs N/A 0 0 N/A N/A N/A self ds ds N/A N/A self stride ds N/A N/A self start start N/A N/A self copy_non_contiguous 0 N/A N/A ds 0 ds N/A N/A N/A warnings warn non square pool shape and strides different than pool shape hasn't been tested and disabled N/A __eq__ N/A N/A self other N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A N/A N/A type self N/A type other N/A N/A self ds N/A other ds N/A N/A self stride N/A other stride N/A N/A self start N/A other start N/A __hash__ N/A N/A self N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A N/A N/A N/A hash N/A type self N/A hash N/A self ds N/A hash N/A self stride N/A hash N/A self start N/A c_header_dirs N/A N/A self N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A N/A N/A config pthreads inc_dir N/A this_dir N/A N/A config pthreads inc_dir N/A this_dir N/A c_headers N/A N/A self N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A nvmatrix.cuh conv_util.cuh N/A c_lib_dirs N/A N/A self N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A N/A N/A config pthreads lib_dir N/A cuda_convnet_loc N/A N/A config pthreads lib_dir N/A cuda_convnet_loc N/A c_libraries N/A N/A self N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A N/A N/A config pthreads lib N/A cuda_convnet N/A N/A config pthreads lib N/A cuda_convnet N/A c_code_cache_version N/A N/A self N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A 1 N/A _argument_contiguity_check N/A N/A self arg_name N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A 
        if (!CudaNdarray_is_c_contiguous(%%(%(arg_name)s)s))
        {
            if (!(%(class_name_caps)s_COPY_NON_CONTIGUOUS)) {
                PyErr_SetString(PyExc_ValueError,
                    "%(class)s: %(arg_name)s must be C contiguous");
                %%(fail)s;
            }
        }
         N/A class arg_name class_name_caps N/A N/A self __class__ __name__ arg_name N/A N/A N/A N/A self __class__ __name__ upper N/A make_node N/A N/A self images top_down N/A N/A N/A 
        .. todo::

            WRITEME
         N/A images N/A as_cuda_ndarray_variable images N/A top_down N/A as_cuda_ndarray_variable top_down N/A N/A N/A images ndim 4 N/A N/A N/A top_down ndim 4 N/A channels_broadcastable N/A N/A N/A images type broadcastable N/A 0 N/A batch_broadcastable N/A N/A N/A images type broadcastable N/A 3 N/A rows_broadcastable False N/A cols_broadcastable False N/A houtput_broadcastable N/A channels_broadcastable rows_broadcastable cols_broadcastable batch_broadcastable N/A houtput_type N/A CudaNdarrayType broadcastable houtput_broadcastable N/A houtput N/A houtput_type N/A poutput_broadcastable N/A channels_broadcastable rows_broadcastable cols_broadcastable batch_broadcastable N/A poutput_type N/A CudaNdarrayType broadcastable poutput_broadcastable N/A poutput N/A poutput_type N/A N/A Apply self N/A images top_down N/A houtput poutput N/A c_code N/A N/A self node name inputs outputs sub N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A images top_down inputs N/A N/A ptargets htargets outputs N/A fail N/A sub N/A fail N/A num_braces 0 N/A N/A self copy_non_contiguous N/A N/A N/A UnimplementedError N/A N/A basic_setup #define PROBMAXPOOL_COPY_NON_CONTIGUOUS 0
 N/A setup_nv_images N/A N/A N/A self _argument_contiguity_check images 
        if (%(images)s->nd != 4)
        {
            PyErr_Format(PyExc_ValueError,
                "images must have nd=4, got nd=%%i", %(images)s->nd);
            %(fail)s;
        }

        { //setup_nv_images brace 1

        const int * images_dims = CudaNdarray_HOST_DIMS(%(images)s);
        const int img_channels = images_dims[0];
        const int imgSizeY = images_dims[1];
        const int imgSizeX = images_dims[2];
        const int batch_size = images_dims[3];

        if(imgSizeY != imgSizeX){
            PyErr_Format(PyExc_ValueError,
                "images must be square(dims[1] == dims[2]). Shape (%%i,%%i,%%i,%%i)",
                img_channels, imgSizeY, imgSizeX, batch_size);
            %(fail)s;
        }
        if(%(ds)s > imgSizeY){
            PyErr_Format(PyExc_ValueError,
                "ds(%%d) must be <= imgSizeX(%%d) and imgSizeY(%%d).",
                %(ds)s, imgSizeX, imgSizeY);
            %(fail)s;
        }
        if(%(start)s >= imgSizeX){
            PyErr_Format(PyExc_ValueError,
                "start is %%d but must be smaller then the images size of %%d x %%d.",
                %(start)s, imgSizeX, imgSizeY);
            %(fail)s;
        }

        NVMatrix nv_images(%(images)s, img_channels * imgSizeY * imgSizeX, batch_size,
        "ProbMaxPool:nv_images");
         N/A num_braces 1 N/A setup_nv_top_down N/A N/A N/A self _argument_contiguity_check top_down 
        if (%(top_down)s->nd != 4)
        {
            PyErr_Format(PyExc_ValueError,
                "top_down must have nd=4, got nd=%%i", %(images)s->nd);
            %(fail)s;
        }

        { //setup_nv_images brace 1

        int _outputsX = ((int)(ceil((imgSizeY - %(start)s - %(ds)s) / ((float)%(stride)s)))) + 1;


        NVMatrix nv_top_down(%(top_down)s, img_channels * _outputsX * _outputsX, batch_size,
        "ProbMaxPool:nv_top_down");
         N/A num_braces 1 N/A setup_nv_ptargets 
        //int _outputsX = ((int)(ceil((imgSizeY - %(start)s - %(ds)s) / ((float)%(stride)s)))) + 1;

        int target_dims [] = {
            img_channels,
            _outputsX,
            _outputsX,
            batch_size };

        if (CudaNdarray_prep_output(& %(ptargets)s, 4, target_dims))
        {
            %(fail)s;
        }

        { // setup_nv_target brace # 1

        NVMatrix nv_ptargets(%(ptargets)s, target_dims[0] * target_dims[1] * target_dims[2],
                            target_dims[3], "ProbMaxPool:nv_ptargets");

         N/A num_braces 1 N/A setup_nv_htargets 
        int target_dims [] = {
            img_channels,
            imgSizeX,
            imgSizeY,
            batch_size };

        if (CudaNdarray_prep_output(& %(htargets)s, 4, target_dims))
        {
            %(fail)s;
        }

        { // setup_nv_target brace # 1

        NVMatrix nv_htargets(%(htargets)s, target_dims[0] * target_dims[1] * target_dims[2],
                            target_dims[3], "ProbMaxPool:nv_htargets");

         N/A num_braces 1 N/A do_pool 
        probabilisticPool(nv_images, nv_top_down, nv_ptargets, nv_htargets, img_channels, %(ds)s,
                      %(start)s, %(stride)s, _outputsX, MaxPooler());
         N/A braces N/A } num_braces N/A rval N/A N/A N/A N/A N/A N/A basic_setup setup_nv_images setup_nv_top_down setup_nv_ptargets setup_nv_htargets do_pool braces N/A start N/A self start N/A stride N/A self stride N/A ds N/A self ds N/A rval N/A rval N/A locals N/A rval N/A grad N/A N/A self inp grads N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A x top_down inp N/A N/A p h N/A self x top_down N/A N/A gp gh grads N/A gp_iszero 0.0 N/A gh_iszero 0.0 N/A N/A isinstance N/A gp type N/A N/A theano gradient DisconnectedType N/A N/A gp N/A N/A tensor zeros_like p N/A gp_iszero 1.0 N/A N/A isinstance N/A gh type N/A N/A theano gradient DisconnectedType N/A N/A gh N/A N/A tensor zeros_like h N/A gh_iszero 1.0 N/A gp N/A gpu_contiguous gp N/A gh N/A gpu_contiguous gh N/A gp_iszero N/A as_cuda_ndarray_variable gp_iszero N/A gh_iszero N/A as_cuda_ndarray_variable gh_iszero N/A N/A N/A ProbMaxPoolGrad N/A self ds N/A self stride N/A self start p h gp gh gp_iszero gh_iszero N/A make_thunk N/A N/A self node storage_map compute_map no_recycling N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A N/A convnet_available N/A N/A N/A RuntimeError Could not compile cuda_convnet N/A N/A N/A N/A super ProbMaxPool self make_thunk node storage_map compute_map no_recycling N/A N/A ProbMaxPoolGrad N/A GpuOp N/A N/A 
    .. todo::

        WRITEME
     __init__ N/A N/A self ds stride start N/A N/A N/A N/A self ds ds N/A N/A self stride stride N/A N/A self start start N/A N/A self copy_non_contiguous 0 N/A N/A N/A stride 0 N/A stride ds N/A stride ds N/A N/A ds 0 ds N/A __eq__ N/A N/A self other N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A N/A N/A type self N/A type other N/A N/A self ds N/A other ds N/A N/A self stride N/A other stride N/A N/A self start N/A other start N/A __hash__ N/A N/A self N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A N/A N/A N/A hash N/A type self N/A hash N/A self ds N/A hash N/A self stride N/A hash N/A self start N/A c_header_dirs N/A N/A self N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A N/A N/A config pthreads inc_dir N/A this_dir N/A N/A config pthreads inc_dir N/A this_dir N/A c_headers N/A N/A self N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A nvmatrix.cuh conv_util.cuh N/A c_lib_dirs N/A N/A self N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A N/A N/A config pthreads lib_dir N/A cuda_convnet_loc N/A N/A config pthreads lib_dir N/A cuda_convnet_loc N/A c_libraries N/A N/A self N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A N/A N/A config pthreads lib N/A cuda_convnet N/A N/A config pthreads lib N/A cuda_convnet N/A c_code_cache_version N/A N/A self N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A 1 N/A _argument_contiguity_check N/A N/A self arg_name N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A 
        if (!CudaNdarray_is_c_contiguous(%%(%(arg_name)s)s))
        {
            if (!(%(class_name_caps)s_COPY_NON_CONTIGUOUS)) {
                PyErr_SetString(PyExc_ValueError,
                    "%(class)s: %(arg_name)s must be C contiguous");
                %%(fail)s;
            }
        }
         N/A class arg_name class_name_caps N/A N/A self __class__ __name__ arg_name N/A N/A N/A N/A self __class__ __name__ upper N/A make_node N/A N/A self p h gp gh gp_iszero gh_iszero N/A N/A N/A 
        .. todo::

            WRITEME
         N/A p N/A as_cuda_ndarray_variable p N/A h N/A as_cuda_ndarray_variable h N/A gp N/A as_cuda_ndarray_variable gp N/A gh N/A as_cuda_ndarray_variable gh N/A N/A N/A p ndim 4 N/A N/A N/A h ndim 4 N/A N/A N/A gp ndim 4 N/A N/A N/A gh ndim 4 N/A N/A N/A nb_channel N/A int N/A get_scalar_constant_value N/A N/A h shape N/A 0 N/A N/A N/A nb_channel 16 0 N/A N/A N/A NotScalarConstantError N/A N/A N/A N/A Apply self N/A p h gp gh gp_iszero gh_iszero N/A N/A N/A p type N/A N/A h type N/A c_code N/A N/A self node name inputs outputs sub N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A p h gp gh gp_iszero gh_iszero inputs N/A N/A targets_z targets_t outputs N/A fail N/A sub N/A fail N/A num_braces 0 N/A N/A self copy_non_contiguous N/A N/A N/A UnimplementedError N/A N/A basic_setup #define PROBMAXPOOLGRAD_COPY_NON_CONTIGUOUS 0
 N/A setup_nv_h N/A N/A N/A self _argument_contiguity_check h 
        if (%(h)s->nd != 4)
        {
            PyErr_Format(PyExc_ValueError,
                "h must have nd=4, got nd=%%i", %(h)s->nd);
            %(fail)s;
        }

        { //setup_nv_images brace 1

        const int * images_dims = CudaNdarray_HOST_DIMS(%(h)s);
        const int img_channels = images_dims[0];
        const int imgSizeY = images_dims[1];
        const int imgSizeX = images_dims[2];
        const int batch_size = images_dims[3];

        if(imgSizeY != imgSizeX){
            PyErr_Format(PyExc_ValueError,
                "images must be square(dims[1] == dims[2]). Shape (%%i,%%i,%%i,%%i)",
                img_channels, imgSizeY, imgSizeX, batch_size);
            %(fail)s;
        }
        if(%(ds)s > imgSizeY){
            PyErr_Format(PyExc_ValueError,
                "ds(%%d) must be <= imgSizeX(%%d) and imgSizeY(%%d).",
                %(ds)s, imgSizeX, imgSizeY);
            %(fail)s;
        }
        if (CudaNdarray_HOST_DIMS(%(h)s)[0] %% 16 != 0)
        {
            PyErr_Format(PyExc_ValueError,
                "h must have a number of channels that is a multiple of 16. Got %%d",
                CudaNdarray_HOST_DIMS(%(gh)s)[0]);
            %(fail)s;
        }


        NVMatrix nv_h(%(h)s, img_channels * imgSizeY * imgSizeX,
                          batch_size, "ProbMaxPool:nv_h");

         N/A num_braces 1 N/A setup_nv_p N/A N/A N/A self _argument_contiguity_check p 
        if (%(p)s->nd != 4)
        {
            PyErr_Format(PyExc_ValueError,
                "P must have nd=4, got nd=%%i", %(p)s->nd);
            %(fail)s;
        }

        { //setup_nv_images brace 1

        int _outputsX = ((int)(ceil((imgSizeY - %(start)s - %(ds)s) / ((float)%(stride)s)))) + 1;


        NVMatrix nv_p(%(p)s, img_channels * _outputsX * _outputsX, batch_size,
        "ProbMaxPool:nv_p");
         N/A num_braces 1 N/A setup_nv_gh N/A N/A N/A self _argument_contiguity_check gh 
        if (%(gh)s->nd != 4)
        {
            PyErr_Format(PyExc_ValueError,
                "gh must have nd=4, got nd=%%i", %(gh)s->nd);
            %(fail)s;
        }
        if (CudaNdarray_HOST_DIMS(%(gh)s)[0] %% 16 != 0)
        {
            PyErr_Format(PyExc_ValueError,
                "gh must have a number of channels that is a multiple of 16. Got %%d",
                CudaNdarray_HOST_DIMS(%(gh)s)[0]);
            %(fail)s;
        }

        { //setup_nv_gh brace 1

        const int * gh_dims = CudaNdarray_HOST_DIMS(%(gh)s);
        const int gh_channels = gh_dims[0];
        const int ghSizeY = gh_dims[1];
        const int ghSizeX = gh_dims[2];

        NVMatrix nv_gh(%(gh)s, gh_channels * ghSizeY * ghSizeX,
                       batch_size, "ProbMaxPool:nv_gh");
         N/A num_braces 1 N/A setup_nv_gp N/A N/A N/A self _argument_contiguity_check gp 
        if (%(gp)s->nd != 4)
        {
            PyErr_Format(PyExc_ValueError,
                "gp must have nd=4, got nd=%%i", %(gp)s->nd);
            %(fail)s;
        }

        { //setup_nv_images brace 1

        int _outputsX = ((int)(ceil((imgSizeY - %(start)s - %(ds)s) / ((float)%(stride)s)))) + 1;


        NVMatrix nv_gp(%(gp)s, img_channels * _outputsX * _outputsX, batch_size,
        "ProbMaxPool:nv_gp");
         N/A num_braces 1 N/A setup_nv_targets_z 
        int target_z_dims [] = {
            img_channels,
            imgSizeX,
            imgSizeY,
            batch_size };

        if (CudaNdarray_prep_output(& %(targets_z)s, 4, target_z_dims))
        {
            %(fail)s;
        }

        { // setup_nv_target brace # 1

        NVMatrix nv_targets_z(%(targets_z)s,
                            target_z_dims[0] * target_z_dims[1] * target_z_dims[2],
                            target_z_dims[3], "ProbMaxPool:nv_targets_z");

         N/A num_braces 1 N/A setup_nv_targets_t 
        int target_t_dims [] = {
            img_channels,
            _outputsX,
            _outputsX,
            batch_size };

        if (CudaNdarray_prep_output(& %(targets_t)s, 4, target_t_dims))
        {
            %(fail)s;
        }

        { // setup_nv_target brace # 1

        NVMatrix nv_targets_t(%(targets_t)s, target_t_dims[0] * target_t_dims[1] * target_t_dims[2],
                            target_t_dims[3], "ProbMaxPool:nv_targets_t");


        float * gp_iszero = CudaNdarray_DEV_DATA(%(gp_iszero)s);
        float * gh_iszero = CudaNdarray_DEV_DATA(%(gh_iszero)s);
         N/A num_braces 1 N/A undo_pool 
        localProbMaxUndo(nv_h, nv_p, nv_gh, nv_gp, nv_targets_z, nv_targets_t,
                         %(ds)s, %(start)s, %(stride)s, _outputsX, imgSizeX, gp_iszero, gh_iszero);
         N/A braces N/A } num_braces N/A rval N/A N/A N/A N/A N/A N/A N/A N/A basic_setup setup_nv_h setup_nv_p setup_nv_gh setup_nv_gp setup_nv_targets_z setup_nv_targets_t undo_pool braces N/A start N/A self start N/A stride N/A self stride N/A ds N/A self ds N/A rval N/A rval N/A locals N/A rval N/A make_thunk N/A N/A self node storage_map compute_map no_recycling N/A N/A N/A 
        .. todo::

            WRITEME
         N/A N/A N/A convnet_available N/A N/A N/A RuntimeError Could not compile cuda_convnet N/A N/A N/A N/A super ProbMaxPoolGrad self make_thunk node storage_map compute_map no_recycling N/A N/A