   long inputHeight  = input->size[1];
   long inputWidth   = input->size[2];
   long batchSize    = input->size[3];
-  long outputHeight = (inputHeight - kH) / dH + 1;
-  long outputWidth  = (inputWidth - kW) / dW + 1;
+  long outputHeight = (padding + inputHeight - kH) / dH + 1;
+  long outputWidth  = (padding + inputWidth - kW) / dW + 1;
 
   // resize output
   THCudaTensor_resize4d(output, nOutputPlane, outputHeight, outputWidth, batchSize);

    nInputPlane, inputHeight, inputWidth, batchSize,
    nOutputPlane, outputHeight, outputWidth,
    kH, kW,
    0, dW,
    0, scale
  );


  
  int dW = luaT_getfieldcheckint(L, 1, "dW");
  int dH = luaT_getfieldcheckint(L, 1, "dH");
  int padding = luaT_getfieldcheckint(L, 1, "padding");
  float scale = luaL_optnumber(L, 4, 1);

  long nOutputPlane = gradWeight->size[3];
