Module ImportFrom alias Import alias identifier Import alias ImportFrom alias identifier ImportFrom alias ImportFrom alias ImportFrom alias ClassDef bases AttributeLoad NameLoad attr body Expr Str Assign NameStore TupleLoad FunctionDef arguments args NameParam defaults body Return TupleLoad Num decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Return Call AttributeLoad NameLoad attr NameLoad keyword ListLoad NameLoad NameLoad NameLoad NameLoad keyword ListLoad Call Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Assign TupleStore NameStore NameStore NameStore NameStore AttributeLoad NameLoad attr Return ListLoad TupleLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num decorator_list FunctionDef arguments args NameParam NameParam defaults body Return ListLoad ListLoad NameLoad ListLoad NameLoad ListLoad NameLoad ListLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Assign TupleStore NameStore NameStore NameStore NameStore NameLoad Assign TupleStore NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad ExtSlice Index Num Index Num Index Num Index Num Slice Assign NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad NameLoad NameLoad NameLoad SubscriptLoad AttributeLoad NameLoad attr Slice Num Num Assign NameStore Call NameLoad NameLoad Num NameLoad Assign NameStore Call Call NameLoad Assign NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad NameLoad Call AttributeLoad NameLoad attr SubscriptLoad NameLoad ExtSlice Index Num Index Num Index Num Index Num Slice NameLoad Return ListLoad NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Assign TupleStore NameStore NameStore NameStore NameStore NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index Num Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index Num Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index Num Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index Num Assert CompareEq SubscriptLoad AttributeLoad NameLoad attr Index Num NameLoad Assign TupleStore NameStore NameStore NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad NameLoad attr For NameStore Call NameLoad Num SubscriptLoad NameLoad Index Num body For NameStore Call NameLoad Num SubscriptLoad NameLoad Index Num body For NameStore Call NameLoad Num SubscriptLoad NameLoad Index Num body For NameStore Call NameLoad Num NameLoad body For NameStore Call NameLoad Num NameLoad body For NameStore Call NameLoad Num NameLoad body For NameStore Call NameLoad Num NameLoad body For NameStore Call NameLoad Num SubscriptLoad NameLoad Index Num body For NameStore Call NameLoad Num SubscriptLoad NameLoad Index Num body AugAssignAdd SubscriptStore NameLoad Index TupleLoad NameLoad NameLoad NameLoad NameLoad NameLoad BinOpMult SubscriptLoad NameLoad Index TupleLoad NameLoad NameLoad NameLoad NameLoad NameLoad SubscriptLoad NameLoad Index TupleLoad NameLoad BinOpAdd BinOpMult NameLoad NameLoad NameLoad BinOpAdd BinOpMult NameLoad NameLoad NameLoad BinOpAdd BinOpMult NameLoad NameLoad NameLoad NameLoad Assign SubscriptStore SubscriptLoad NameLoad Index Num Index Num NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults body Assign TupleStore NameStore NameStore NameStore NameStore NameLoad Assign NameStore SubscriptLoad NameLoad Index Str Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore Str Return Call AttributeLoad NameLoad attr NameLoad Call NameLoad decorator_list decorator_list Assign NameStore Call NameLoad
N/A six.moves xrange N/A numpy N N/A theano theano.tensor basic T theano.misc strutil theano.gradient grad_undefined theano.gradient DisconnectedType ConvGrad3D N/A N/A theano Op N/A N/A 
    Gradient of Conv3D with respect to W.

     N/A __props__ N/A c_code_cache_version N/A N/A self N/A N/A N/A N/A 1 N/A make_node N/A N/A self V d WShape dCdH N/A N/A N/A V_ N/A N/A T as_tensor_variable V N/A d_ N/A N/A T as_tensor_variable d N/A WShape_ N/A N/A T as_tensor_variable WShape N/A dCdH_ N/A N/A T as_tensor_variable dCdH N/A N/A N/A theano Apply self inputs N/A V_ d_ WShape_ dCdH_ outputs N/A N/A N/A N/A T TensorType N/A V_ dtype N/A False False False False False N/A infer_shape N/A N/A self node input_shapes N/A N/A N/A N/A V d W_shape dCdH N/A node inputs N/A N/A N/A N/A W_shape N/A 0 N/A W_shape N/A 1 N/A W_shape N/A 2 N/A W_shape N/A 3 N/A W_shape N/A 4 N/A connection_pattern N/A N/A self node N/A N/A N/A N/A N/A True N/A True N/A False N/A True N/A grad N/A N/A self inputs output_gradients N/A N/A N/A N/A C d WShape B inputs N/A N/A dLdA output_gradients N/A z N/A N/A T zeros_like N/A C N/A N/A 0 N/A 0 N/A 0 N/A 0 N/A N/A dLdC N/A N/A N/A N/A theano tensor nnet convTransp3D dLdA z d B N/A N/A C shape N/A 1 4 N/A dLdd N/A grad_undefined self 1 d N/A dLdWShape N/A N/A DisconnectedType N/A dLdB N/A N/A N/A N/A theano tensor nnet conv3D C dLdA N/A N/A T zeros_like N/A B N/A N/A 0 N/A 0 N/A 0 N/A 0 N/A d N/A N/A dLdC dLdd dLdWShape dLdB N/A perform N/A N/A self node inputs output_storage N/A N/A N/A N/A V d WShape dCdH inputs N/A batchSize N/A N/A dCdH shape N/A 0 N/A outputHeight N/A N/A dCdH shape N/A 1 N/A outputWidth N/A N/A dCdH shape N/A 2 N/A outputDur N/A N/A dCdH shape N/A 3 N/A N/A N/A N/A V shape N/A 0 batchSize N/A N/A dr dc dt d N/A dCdW N/A N/A N zeros WShape dtype N/A V dtype N/A k N/A xrange 0 N/A WShape N/A 1 N/A N/A l N/A xrange 0 N/A WShape N/A 2 N/A N/A m N/A xrange 0 N/A WShape N/A 3 N/A N/A i N/A xrange 0 batchSize N/A N/A p N/A xrange 0 outputHeight N/A N/A q N/A xrange 0 outputWidth N/A N/A r N/A xrange 0 outputDur N/A N/A j N/A xrange 0 N/A WShape N/A 0 N/A N/A z N/A xrange 0 N/A WShape N/A 4 N/A N/A N/A dCdW N/A N/A j k l m z N/A N/A dCdH N/A N/A i p q r j N/A V N/A N/A i N/A N/A dr p k N/A N/A dc q l N/A N/A dt r m z N/A N/A N/A output_storage N/A 0 N/A 0 dCdW N/A c_code N/A N/A self node nodename inputs outputs sub N/A N/A N/A N/A V d WShape dCdH inputs N/A fail N/A sub N/A fail N/A dCdW N/A outputs N/A 0 N/A codeSource 
            ///////////// < code generated by ConvGradW3D >

            //printf("				ConvGradW3D c code\n");

            //Check dimensionality of inputs
            if (PyArray_NDIM(%(dCdH)s) != 5)
            {
                PyErr_Format(PyExc_ValueError, "ConvGrad3D: dCdH must be a 5 dimensional tensor");
                            %(fail)s
            }

            if (PyArray_NDIM(%(V)s) != 5)
            {
                PyErr_Format(PyExc_ValueError, "ConvGrad3D: V must be a 5 dimensional tensor");
                %(fail)s
            }

            if (PyArray_NDIM(%(WShape)s) != 1)
            {
                PyErr_Format(PyExc_ValueError,"ConvGrad3D: WShape must be a vector.");
                %(fail)s
            }

            if (PyArray_NDIM(%(d)s) != 1)
            {
                PyErr_Format(PyExc_ValueError,"ConvGrad3D: d must be a vector.");
                %(fail)s
            }

            if (PyArray_DIMS(%(d)s)[0] != 3)
            {
                PyErr_Format(PyExc_ValueError,"ConvGrad3D: 3 stride length arguments expected (row, col, time) but %%li were given", (long)PyArray_DIMS(%(d)s)[0]);
                %(fail)s
            }
{ //extra scope so that fail will not jump over declarations

            //Read and check sizes of inputs
            const int batchSize = PyArray_DIMS(%(V)s)[0];
            if (PyArray_DIMS(%(WShape)s)[0] != 5)
            {
                PyErr_Format(PyExc_ValueError,"ConvGrad3D: WShape must specify a 5D shape");
                %(fail)s
            }
            if (!PyArray_ISCONTIGUOUS(%(WShape)s))
            {
                PyErr_Format(PyExc_ValueError,"ConvGrad3D: WShape must be contiguous");
                %(fail)s
            }

{ //extra scope so that fail will not jump over declarations
            dtype_%(WShape)s * WShape = (dtype_%(WShape)s *) PyArray_DATA(%(WShape)s);
            const int outputChannels =  WShape[0];
            const int inputChannels = PyArray_DIMS(%(V)s)[4];
            if (WShape[4] != inputChannels)
            {
                PyErr_Format(PyExc_ValueError, "ConvGrad3D: W operates on a %%i channel image but the image has %%i channels",(int) WShape[1],inputChannels);
                %(fail)s

            }
{ //extra scope so fail works
            const int filterHeight = WShape[1];
            const int filterWidth = WShape[2];
            const int filterDur = WShape[3];
            const int vidHeight = PyArray_DIMS(%(V)s)[1];
            const int vidWidth = PyArray_DIMS(%(V)s)[2];
            const int vidDur = PyArray_DIMS(%(V)s)[3];
            if (vidHeight < filterHeight)
            {
                PyErr_Format(PyExc_ValueError, "ConvGrad3D: W has a height of %%i but V is only %%i pixels tall", filterHeight, vidHeight);
                %(fail)s
            }
            if (vidWidth < filterWidth)
            {
                PyErr_Format(PyExc_ValueError,"ConvGrad3D: W has a width of %%i but V is only %%i pixels tall",filterWidth,vidWidth);
                %(fail)s
            }
            if (vidDur < filterDur)
            {
                PyErr_Format(PyExc_ValueError,"ConvGrad3D: W has a duration of %%i but V is only %%i pixels long",filterDur,vidDur);
                %(fail)s
            }

{ // extra scope so fail works
            //Read and check stride arguments
            const int dr = *(dtype_%(d)s*)PyArray_GETPTR1(%(d)s,0);
            const int dc = *(dtype_%(d)s*)PyArray_GETPTR1(%(d)s,1);
            const int dt = *(dtype_%(d)s*)PyArray_GETPTR1(%(d)s,2);
            if (dr <= 0 || dc <= 0 || dt <= 0)
            {
                PyErr_Format(PyExc_ValueError,"ConvGrad3D: Strides should all be positive but they are %%i, %%i, %%i",dr,dc,dt);
                %(fail)s
            }

{ // extra scope so fail works
            //Compute correct sized of output
            const int outputHeight = int( (vidHeight - filterHeight) / dr )+1;
            const int outputWidth = int( (vidWidth - filterWidth) / dc )+1;
            const int outputDur = int( (vidDur - filterDur) / dt ) +1;



            if (PyArray_DIMS(%(dCdH)s)[0] != batchSize ||
                PyArray_DIMS(%(dCdH)s)[4] != outputChannels ||
                PyArray_DIMS(%(dCdH)s)[1] != outputHeight ||
                PyArray_DIMS(%(dCdH)s)[2] != outputWidth ||
                PyArray_DIMS(%(dCdH)s)[3] != outputDur)
            {
                PyErr_Format(PyExc_ValueError, "dCdH is the wrong size, expected (%%i,%%i,%%i,%%i,%%i), got (%%li,%%li,%%li,%%li,%%li)", batchSize,  outputHeight, outputWidth, outputDur, outputChannels, (long)PyArray_DIMS(%(dCdH)s)[0], (long)PyArray_DIMS(%(dCdH)s)[1], (long)PyArray_DIMS(%(dCdH)s)[2], (long)PyArray_DIMS(%(dCdH)s)[3], (long)PyArray_DIMS(%(dCdH)s)[4]);
                %(fail)s
            }
{ // extra scope for fail

            npy_intp dims[5];
            dims[0] = outputChannels;
            dims[4] = inputChannels;
            dims[1] = filterHeight;
            dims[2] = filterWidth;
            dims[3] = filterDur;

            if(!(%(dCdW)s)  || PyArray_DIMS(%(dCdW)s)[0]!=dims[0] ||
                  PyArray_DIMS(%(dCdW)s)[1]!=dims[1] ||
                  PyArray_DIMS(%(dCdW)s)[2]!=dims[2] ||
                  PyArray_DIMS(%(dCdW)s)[3]!=dims[3] ||
                  PyArray_DIMS(%(dCdW)s)[4]!=dims[4] ){
               Py_XDECREF(%(dCdW)s);
               %(dCdW)s = (PyArrayObject *) PyArray_SimpleNew(5, dims, PyArray_DESCR(%(V)s)->type_num);

               if (!(%(dCdW)s)) {
                  PyErr_Format(PyExc_MemoryError,"ConvGrad3D: Could not allocate dCdW");
                %(fail)s
               }
            }
{ //extra scope so fail works

            #define ELEM5(x, i,j,k,l,m) * ( dtype_ ## x *) ( PyArray_BYTES(x) + (i)*PyArray_STRIDES(x)[0]+(j)*PyArray_STRIDES(x)[1]+(k)*PyArray_STRIDES(x)[2]+(l)*PyArray_STRIDES(x)[3]+(m)*PyArray_STRIDES(x)[4] )

            #define ELEM_AT(x, i) * ( dtype_ ## x *) ( PyArray_BYTES(x) + (i) )

            const int dhs3 = PyArray_STRIDES(%(dCdH)s)[3];
            const int dtvs3 = dt * PyArray_STRIDES(%(V)s)[3];

            // Compute dCdW
            //TODO-- see if this can be made faster by using ELEM_AT instead of ELEM5
            // dCdW[j,k,l,m,z] = sum_i sum_p sum_q sum_r dCdH[i,p,q,r,j]  *  V[i,dr*p+k,dc*q+l,dt*r+m,z]
            for (int j = 0; j < outputChannels; j++) {
                for (int z = 0; z < inputChannels; z++) {
                    for (int k = 0; k < filterHeight; k++) {
                        for (int l = 0; l < filterWidth; l++) {
                            for (int m = 0; m < filterDur; m++) {

                                //printf("writePos %%i %%i %%i %%i %%i \n",j,k,l,m,z);

                                dtype_%(dCdW)s & writePos =  ELEM5(%(dCdW)s, j,k,l,m,z);
                                writePos = 0;
                                for (int i = 0; i < batchSize; i++) {
                                    for (int p = 0; p < outputHeight; p++) {
                                        for (int q = 0; q < outputWidth; q++) {
                                            int Hpos = i * PyArray_STRIDES(%(dCdH)s)[0] + j * PyArray_STRIDES(%(dCdH)s)[4] + p * PyArray_STRIDES(%(dCdH)s)[1] + q * PyArray_STRIDES(%(dCdH)s)[2] ;
                                            int Vpos = i * PyArray_STRIDES(%(V)s)[0] + z * PyArray_STRIDES(%(V)s)[4] +  (dr * p+k) * PyArray_STRIDES(%(V)s)[1] +  (dc*q+l) * PyArray_STRIDES(%(V)s)[2] + m * PyArray_STRIDES(%(V)s)[3];

                                            for (int r = 0; r < outputDur; r++) {
                                                writePos += ELEM5(%(dCdH)s,i,p,q,r,j) * ELEM5(%(V)s,i,dr*p+k,dc*q+l,dt*r+m,z);
                                                //writePos += ELEM_AT(%(dCdH)s,Hpos) * ELEM_AT(%(V)s,Vpos);
                                                Hpos += dhs3;
                                                Vpos += dtvs3;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

}}}}}}} // extra scope for fail
            ///////////// < /code generated by ConvGradW3D >
         N/A N/A N/A strutil render_string codeSource N/A locals N/A N/A N/A convGrad3D N/A ConvGrad3D