Why doesn't this convolution work?

[Old posts from the commercial version of ArrayFire] Discussion of ArrayFire using CUDA or OpenCL.

Moderator: pavanky

Why doesn't this convolution work?

Postby rm9 » Thu Jan 30, 2014 5:48 am

Hi,
I'm trying to convolve two matrices in the following sizes, and I get the followig error:
Code: Select all
data(span, span, span, j) dims=[256 64 5]
W(span, span, j) dims=[8 64]
src/gena/gi_subs.cpp:518: error: assignment size mismatch: source 81920, destination 1245


I expected the same behavior as of matlab convn where the result would be a 3d matrix in the size [249 1 5].
Should both matrices be 2d or 3d?

Thanks.
Last edited by rm9 on Thu Jan 30, 2014 12:07 pm, edited 1 time in total.
rm9
 
Posts: 54
Joined: Thu Jan 30, 2014 5:44 am

Re: Why this convolution doesn't work?

Postby shehzan » Thu Jan 30, 2014 11:56 am

Can you please post the segment of code you are using? This will help in debugging the issue.
----
Shehzan
Developer
AccelerEyes
User avatar
shehzan
 
Posts: 121
Joined: Tue Feb 12, 2013 7:20 pm

Re: Why this convolution doesn't work?

Postby rm9 » Thu Jan 30, 2014 11:59 am

I'm calling convolve on these two matrices:
Code: Select all
convolve(data(span, span, span, j), W(span, span, j), false);

If I break down the convolution to multiple convolutions then it works (but probably slower):
Code: Select all
         for (int k = 0; k < data.dims(2); ++k) {
            output(span, span, k, j) =             
               convolve(data(span, span, k, j), W(span, span, j), false);               
            }         
rm9
 
Posts: 54
Joined: Thu Jan 30, 2014 5:44 am

Re: Why this convolution doesn't work?

Postby shehzan » Thu Jan 30, 2014 12:07 pm

As a test, I ran this code:
Code: Select all
array data = randu(256, 64, 5, 3);                                                                                                                                                                                             
array W = randu(8, 64, 3);
array output = convolve(data(span, span, span, 0), W(span, span, 0), false);
printdims(output);
getchar();


It works fine.
You should check the dimensions of the output variable.
If the problem persists, can you provide more information about it?
----
Shehzan
Developer
AccelerEyes
User avatar
shehzan
 
Posts: 121
Joined: Tue Feb 12, 2013 7:20 pm

Re: Why doesn't this convolution work?

Postby rm9 » Thu Jan 30, 2014 12:13 pm

You are right!
I got confused, this was due to my other question regarding the convolution sizes (full,valid, etc.).
Thanks for all your help!
rm9
 
Posts: 54
Joined: Thu Jan 30, 2014 5:44 am


Return to [archive-commercial] Programming & Development with ArrayFire

cron