The problem is that you create the dense version. This will use much more memory. I don't know if it is better to have the slow/memory hungry version or raise an error. As this is only on a batch, it can be acceptable.

Do someone use that? If not, maybe printing a warning about this (via the warning module to have it printed only once).

I have an issue in Theano to implement sparse reshape: https://github.com/Theano/Theano/issues/1742