Performing convolution type operations manually?

I feel like I have missed something obvious. How to perform operations on tensors of different sizes.

Lets say I wanted to use a 3x3x3 to perform elementwise operations that I could define on for example a 3x32x32. Is there a simple way to do this?

For example what if I wanted to perform elementwise add, sub div and sum? As opposed to mul with sum.

Or for a different example if I had an existing net with a 3x32x32 input and wanted to stride it along a 3x64x64

A naïve approach would be to get an NDArray section by index and apply the above process in a loop. Which is actually doable for my purposes.

A better approach would be to break the larger tensor into smaller tensors and apply the process in parallel. Not sure how this would be done.

Maybe I’m missing something else completely.
If there is no set up solution or the question is dumb please drop me a quick “no” or if you can even throw me even a quick lead that would be great @agibsonccc @treo

@cagneymoreau generally 2 and 3d convolutions already cover your use case. What are you trying to do exactly?

I want an easy way to locate a simple object in an image.

    INDArray result = ND4j.3Dconvolution(imgtensor, filtertensor, padding?, stride?);

So the above code would (at least in my imagination) just be a quick way getting that info. Since the object im tracking never changes I was going to just use it as the filter itself instead of mul, sum I could use div, sum, an then div by tensor length would give me a 1 at its exact location

Of for more complicated images I may even use an overtrained network to find objects within an image.

Any reason why doesn’t work for you?

1 Like

Yes, thats exactly what I was looking for.