"neib_step wrong step ; has to contain 2 elements");
"neib_step wrong step ; has to contain 2 elements");
...
@@ -154,33 +154,33 @@ class Images2Neibs(Op):
...
@@ -154,33 +154,33 @@ class Images2Neibs(Op):
PyErr_Format(PyExc_TypeError, "Images2Neibs: in mode wrap_centered need patch with odd shapes");
PyErr_Format(PyExc_TypeError, "Images2Neibs: in mode wrap_centered need patch with odd shapes");
%(fail)s;
%(fail)s;
}
}
if ( (%(ten4)s->dimensions)[2] < c || (%(ten4)s->dimensions)[3] < d)
if ( (PyArray_DIMS(%(ten4)s))[2] < c || (PyArray_DIMS(%(ten4)s))[3] < d)
{
{
PyErr_Format(PyExc_TypeError, "Images2Neibs: in wrap_centered mode, don't support image shapes smaller then the patch shapes: neib_shape=(%%ld,%%ld), ten4[2:]=[%%ld,%%ld]",
PyErr_Format(PyExc_TypeError, "Images2Neibs: in wrap_centered mode, don't support image shapes smaller then the patch shapes: neib_shape=(%%ld,%%ld), ten4[2:]=[%%ld,%%ld]",
PyErr_Format(PyExc_ValueError, "Conv3D: W must be a 5 dimensional tensor");
PyErr_Format(PyExc_ValueError, "Conv3D: W must be a 5 dimensional tensor");
%(fail)s
%(fail)s
}
}
if (%(V)s->nd != 5)
if (PyArray_NDIM(%(V)s) != 5)
{
{
PyErr_Format(PyExc_ValueError, "Conv3D: V must be a 5 dimensional tensor");
PyErr_Format(PyExc_ValueError, "Conv3D: V must be a 5 dimensional tensor");
%(fail)s
%(fail)s
}
}
if (%(b)s->nd != 1)
if (PyArray_NDIM(%(b)s) != 1)
{
{
PyErr_Format(PyExc_ValueError,"Conv3D: b must be a vector.");
PyErr_Format(PyExc_ValueError,"Conv3D: b must be a vector.");
%(fail)s
%(fail)s
}
}
if (%(d)s->nd != 1)
if (PyArray_NDIM(%(d)s) != 1)
{
{
PyErr_Format(PyExc_ValueError,"Conv3D: d must be a vector.");
PyErr_Format(PyExc_ValueError,"Conv3D: d must be a vector.");
%(fail)s
%(fail)s
}
}
if (%(d)s->dimensions[0] != 3)
if (PyArray_DIMS(%(d)s)[0] != 3)
{
{
PyErr_Format(PyExc_ValueError,"Conv3D: 3 stride length arguments expected (row, col, time) but %%li were given", (long)%(d)s->dimensions[0]);
PyErr_Format(PyExc_ValueError,"Conv3D: 3 stride length arguments expected (row, col, time) but %%li were given", (long)PyArray_DIMS(%(d)s)[0]);
%(fail)s
%(fail)s
}
}
//Read and check sizes of inputs
//Read and check sizes of inputs
{ // exta scope so error handler jumps don't cause errors
{ // exta scope so error handler jumps don't cause errors
const int batchSize = %(V)s->dimensions[0];
const int batchSize = PyArray_DIMS(%(V)s)[0];
const int outputChannels = %(W)s->dimensions[0];
const int outputChannels = PyArray_DIMS(%(W)s)[0];
const int inputChannels = %(V)s->dimensions[4];
const int inputChannels = PyArray_DIMS(%(V)s)[4];
if (%(W)s->dimensions[4] != inputChannels)
if (PyArray_DIMS(%(W)s)[4] != inputChannels)
{
{
PyErr_Format(PyExc_ValueError, "Conv3D: W operates on a %%ld channel image but the image has %%d channels. Overall shape of input: (%%ld,%%ld,%%ld,%%ld,%%ld)", (long)%(W)s->dimensions[4], inputChannels, (long)%(V)s->dimensions[0], (long)%(V)s->dimensions[1], (long)%(V)s->dimensions[2], (long)%(V)s->dimensions[3], (long)%(V)s->dimensions[4]);
PyErr_Format(PyExc_ValueError, "Conv3D: W operates on a %%ld channel image but the image has %%d channels. Overall shape of input: (%%ld,%%ld,%%ld,%%ld,%%ld)", (long)PyArray_DIMS(%(W)s)[4], inputChannels, (long)PyArray_DIMS(%(V)s)[0], (long)PyArray_DIMS(%(V)s)[1], (long)PyArray_DIMS(%(V)s)[2], (long)PyArray_DIMS(%(V)s)[3], (long)PyArray_DIMS(%(V)s)[4]);
%(fail)s
%(fail)s
}
}
if (%(b)s->dimensions[0] != outputChannels)
if (PyArray_DIMS(%(b)s)[0] != outputChannels)
{
{
PyErr_Format(PyExc_ValueError, "Conv3D: b adds to a(n) %%ld channel output image but the output has %%d channels", (long)%(b)s->dimensions[0], outputChannels);
PyErr_Format(PyExc_ValueError, "Conv3D: b adds to a(n) %%ld channel output image but the output has %%d channels", (long)PyArray_DIMS(%(b)s)[0], outputChannels);
%(fail)s
%(fail)s
}
}
{ //extra scope so error handler jumps don't cause errors
{ //extra scope so error handler jumps don't cause errors
@@ -103,34 +99,36 @@ class ConvTransp3D(theano.Op):
...
@@ -103,34 +99,36 @@ class ConvTransp3D(theano.Op):
//printf("\t\t\t\tConvTransp3D c code\\n");
//printf("\t\t\t\tConvTransp3D c code\\n");
//Check dimensionality of inputs
//Check dimensionality of inputs
if (%(H)s->nd != 5)
if (PyArray_NDIM(%(H)s) != 5)
{
{
PyErr_Format(PyExc_ValueError, "H must be a 5-D tensor but it is %%i-D",%(H)s->nd);
PyErr_Format(PyExc_ValueError,
"H must be a 5-D tensor but it is %%i-D",
PyArray_NDIM(%(H)s));
%(fail)s
%(fail)s
}
}
if (%(W)s->nd != 5)
if (PyArray_NDIM(%(W)s) != 5)
{
{
PyErr_Format(PyExc_ValueError, "ConvTransp3D: W must be a 5-D tensor");
PyErr_Format(PyExc_ValueError, "ConvTransp3D: W must be a 5-D tensor");
%(fail)s
%(fail)s
}
}
if (%(b)s->nd != 1)
if (PyArray_NDIM(%(b)s) != 1)
{
{
PyErr_Format(PyExc_ValueError, "ConvTransp3D: b must be a vector");
PyErr_Format(PyExc_ValueError, "ConvTransp3D: b must be a vector");
%(fail)s
%(fail)s
}
}
if (%(d)s->nd != 1)
if (PyArray_NDIM(%(d)s) != 1)
{
{
PyErr_Format(PyExc_ValueError, "ConvTransp3D: d must be a vector");
PyErr_Format(PyExc_ValueError, "ConvTransp3D: d must be a vector");
%(fail)s
%(fail)s
}
}
//Read and check stride arguments
//Read and check stride arguments
if (%(d)s->dimensions[0] != 3)
if (PyArray_DIMS(%(d)s)[0] != 3)
{
{
PyErr_Format(PyExc_ValueError, "ConvTransp3D: 3 stride length arguments expected (for row, col, and time) but %%li were given", (long)%(d)s->dimensions[0] );
PyErr_Format(PyExc_ValueError, "ConvTransp3D: 3 stride length arguments expected (for row, col, and time) but %%li were given", (long)PyArray_DIMS(%(d)s)[0] );
%(fail)s
%(fail)s
}
}
...
@@ -149,33 +147,33 @@ class ConvTransp3D(theano.Op):
...
@@ -149,33 +147,33 @@ class ConvTransp3D(theano.Op):
//Read and check sizes of inputs
//Read and check sizes of inputs
{ // for fail 2
{ // for fail 2
const int batchSize = %(H)s->dimensions[0];
const int batchSize = PyArray_DIMS(%(H)s)[0];
const int outputChannels = %(W)s->dimensions[0];
const int outputChannels = PyArray_DIMS(%(W)s)[0];
if (%(H)s->dimensions[4] != outputChannels)
if (PyArray_DIMS(%(H)s)[4] != outputChannels)
{
{
PyErr_Format(PyExc_ValueError, "W produces a %%i channel image but the image has %%li channels. W.shape: (%%li, %%li, %%li, %%li, %%li) H.shape: (%%li, %%li, %%li, %%li, %%li)", outputChannels, (long)%(H)s->dimensions[4], (long)%(W)s->dimensions[0], (long)%(W)s->dimensions[1], (long)%(W)s->dimensions[2], (long)%(W)s->dimensions[3], (long)%(W)s->dimensions[4], (long)%(H)s->dimensions[0], (long)%(H)s->dimensions[1], (long)%(H)s->dimensions[2], (long)%(H)s->dimensions[3], (long)%(H)s->dimensions[4]);
PyErr_Format(PyExc_ValueError, "W produces a %%i channel image but the image has %%li channels. W.shape: (%%li, %%li, %%li, %%li, %%li) H.shape: (%%li, %%li, %%li, %%li, %%li)", outputChannels, (long)PyArray_DIMS(%(H)s)[4], (long)PyArray_DIMS(%(W)s)[0], (long)PyArray_DIMS(%(W)s)[1], (long)PyArray_DIMS(%(W)s)[2], (long)PyArray_DIMS(%(W)s)[3], (long)PyArray_DIMS(%(W)s)[4], (long)PyArray_DIMS(%(H)s)[0], (long)PyArray_DIMS(%(H)s)[1], (long)PyArray_DIMS(%(H)s)[2], (long)PyArray_DIMS(%(H)s)[3], (long)PyArray_DIMS(%(H)s)[4]);
%(fail)s
%(fail)s
}
}
{ // for fail 3
{ // for fail 3
const int inputChannels = %(W)s->dimensions[4];
const int inputChannels = PyArray_DIMS(%(W)s)[4];
if (%(b)s->dimensions[0] != inputChannels)
if (PyArray_DIMS(%(b)s)[0] != inputChannels)
{
{
PyErr_Format(PyExc_ValueError, "ConvTransp3D: b operates on a %%li channel image but the image has %%i channels", (long)%(b)s->dimensions[0], inputChannels );
PyErr_Format(PyExc_ValueError, "ConvTransp3D: b operates on a %%li channel image but the image has %%i channels", (long)PyArray_DIMS(%(b)s)[0], inputChannels );
%(fail)s
%(fail)s
}
}
{ // for fail 4
{ // for fail 4
const int filterHeight = %(W)s->dimensions[1];
const int filterHeight = PyArray_DIMS(%(W)s)[1];
const int filterWidth = %(W)s->dimensions[2];
const int filterWidth = PyArray_DIMS(%(W)s)[2];
const int filterDur = %(W)s->dimensions[3];
const int filterDur = PyArray_DIMS(%(W)s)[3];
const int outputHeight = %(H)s->dimensions[1];
const int outputHeight = PyArray_DIMS(%(H)s)[1];
const int outputWidth = %(H)s->dimensions[2];
const int outputWidth = PyArray_DIMS(%(H)s)[2];
const int outputDur = %(H)s->dimensions[3];
const int outputDur = PyArray_DIMS(%(H)s)[3];
int videoHeight = (outputHeight-1) * dr + filterHeight;
int videoHeight = (outputHeight-1) * dr + filterHeight;
int videoWidth = (outputWidth-1) * dc + filterWidth;
int videoWidth = (outputWidth-1) * dc + filterWidth;
...
@@ -183,13 +181,13 @@ class ConvTransp3D(theano.Op):
...
@@ -183,13 +181,13 @@ class ConvTransp3D(theano.Op):
if (%(RShape)s)
if (%(RShape)s)
{
{
if (%(RShape)s->nd != 1)
if (PyArray_NDIM(%(RShape)s) != 1)
{
{
PyErr_Format(PyExc_ValueError, "ConvTransp3D: RShape must be a vector");
PyErr_Format(PyExc_ValueError, "ConvTransp3D: RShape must be a vector");
%(fail)s
%(fail)s
}
}
if (%(RShape)s->dimensions[0] != 3)
if (PyArray_DIMS(%(RShape)s)[0] != 3)
{
{
PyErr_Format(PyExc_ValueError, "RShape must specify a 3D shape ( [height,width,duration] )");
PyErr_Format(PyExc_ValueError, "RShape must specify a 3D shape ( [height,width,duration] )");
%(fail)s
%(fail)s
...
@@ -223,14 +221,14 @@ class ConvTransp3D(theano.Op):
...
@@ -223,14 +221,14 @@ class ConvTransp3D(theano.Op):