Discussion:
[theano-users] Convolution with sparse input image
Peter O'Connor
2016-08-16 15:29:31 UTC
Permalink
I'm looking for an efficient to do convolution when the input
images/feature maps are sparse.

So you'd have a sparse input (n_samples, n_features_in, n_rows, n_cols), a
dense kernel (n_features_out, n_features_in, n_kernel_rows, n_kernel_cols),
and produce either a sparse or dense output of shape (n_samples,
n_features_out, n_rows +n_kernel_rows-1, n_cols+n_kernel_cols-1).

I've seen theano's sparse sandbox
<http://deeplearning.net/software/theano/library/sparse/sandbox.html>, but
it's not obvious from here that it would support this kind of operation (it
seems to be more about implementing dense convolutions as sparse matrix
multiplications). Does anybody know of existing code that deals with this
situation?
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Peter O'Connor
2016-08-16 15:31:04 UTC
Permalink
I'm looking for an efficient way to do convolution when the input
images/feature maps are sparse.

So you'd have a sparse input (n_samples, n_features_in, n_rows, n_cols), a
dense kernel (n_features_out, n_features_in, n_kernel_rows, n_kernel_cols),
and produce either a sparse or dense output of shape (n_samples,
n_features_out, n_rows +n_kernel_rows-1, n_cols+n_kernel_cols-1).

I've seen theano's sparse sandbox
<http://deeplearning.net/software/theano/library/sparse/sandbox.html>, but
it's not obvious from here that it would support this kind of operation (it
seems to be more about implementing dense convolutions as sparse matrix
multiplications). Does anybody know of existing code that deals with this
situation?
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Frédéric Bastien
2016-08-17 13:41:00 UTC
Permalink
What is the % of sparcity? On the GPU if it isn't high, it won't speed up
the computation to do sparse computation.

We have some block sparse operation in that module, maybe it can help you:

http://deeplearning.net/software/theano/library/tensor/nnet/blocksparse.html?highlight=block%20sparse#module-tensor.nnet.blocksparse
Post by Peter O'Connor
I'm looking for an efficient way to do convolution when the input
images/feature maps are sparse.
So you'd have a sparse input (n_samples, n_features_in, n_rows, n_cols), a
dense kernel (n_features_out, n_features_in, n_kernel_rows, n_kernel_cols),
and produce either a sparse or dense output of shape (n_samples,
n_features_out, n_rows +n_kernel_rows-1, n_cols+n_kernel_cols-1).
I've seen theano's sparse sandbox
<http://deeplearning.net/software/theano/library/sparse/sandbox.html>,
but it's not obvious from here that it would support this kind of operation
(it seems to be more about implementing dense convolutions as sparse matrix
multiplications). Does anybody know of existing code that deals with this
situation?
--
---
You received this message because you are subscribed to the Google Groups
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Peter O'Connor
2016-08-17 17:36:34 UTC
Permalink
Well it varies but about 1%. I figure on the GPU it won't do much, I'm
hoping this will work when distributed across a bunch of CPUs.

Thanks, I'll check block_sparse and see if that helps, and post solution
here if I find one.
Post by Frédéric Bastien
What is the % of sparcity? On the GPU if it isn't high, it won't speed up
the computation to do sparse computation.
http://deeplearning.net/software/theano/library/tensor/nnet/blocksparse.html?highlight=block%20sparse#module-tensor.nnet.blocksparse
Post by Peter O'Connor
I'm looking for an efficient way to do convolution when the input
images/feature maps are sparse.
So you'd have a sparse input (n_samples, n_features_in, n_rows, n_cols),
a dense kernel (n_features_out, n_features_in, n_kernel_rows,
n_kernel_cols), and produce either a sparse or dense output of shape
(n_samples, n_features_out, n_rows +n_kernel_rows-1,
n_cols+n_kernel_cols-1).
I've seen theano's sparse sandbox
<http://deeplearning.net/software/theano/library/sparse/sandbox.html>,
but it's not obvious from here that it would support this kind of operation
(it seems to be more about implementing dense convolutions as sparse matrix
multiplications). Does anybody know of existing code that deals with this
situation?
--
---
You received this message because you are subscribed to the Google Groups
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
martin.gromniak via theano-users
2017-10-16 10:08:06 UTC
Permalink
Hi Peter,

may i ask in what context you used sparse images as input to conv nets? I
am struggeling with designing a conv net architecture for artificial and
sparse images.
Can you point me in any direction?

Thanks in advance,
Martin
Post by Peter O'Connor
Well it varies but about 1%. I figure on the GPU it won't do much, I'm
hoping this will work when distributed across a bunch of CPUs.
Thanks, I'll check block_sparse and see if that helps, and post solution
here if I find one.
Post by Frédéric Bastien
What is the % of sparcity? On the GPU if it isn't high, it won't speed up
the computation to do sparse computation.
http://deeplearning.net/software/theano/library/tensor/nnet/blocksparse.html?highlight=block%20sparse#module-tensor.nnet.blocksparse
Post by Peter O'Connor
I'm looking for an efficient way to do convolution when the input
images/feature maps are sparse.
So you'd have a sparse input (n_samples, n_features_in, n_rows, n_cols),
a dense kernel (n_features_out, n_features_in, n_kernel_rows,
n_kernel_cols), and produce either a sparse or dense output of shape
(n_samples, n_features_out, n_rows +n_kernel_rows-1,
n_cols+n_kernel_cols-1).
I've seen theano's sparse sandbox
<http://deeplearning.net/software/theano/library/sparse/sandbox.html>,
but it's not obvious from here that it would support this kind of operation
(it seems to be more about implementing dense convolutions as sparse matrix
multiplications). Does anybody know of existing code that deals with this
situation?
--
---
You received this message because you are subscribed to the Google
Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...