Lasagne
Lasagne copied to clipboard
Support of scalar inputs
Hello!
The documentation of InputLayer says that I can pass input shape as int (in order to get scalar input in my network). http://lasagne.readthedocs.io/en/latest/modules/layers/input.html#lasagne.layers.InputLayer
However, if you actually pass int as a shape parameter to the InputLayer it fails with an error:
if any(d is not None and d <= 0 for d in self.shape):
TypeError: 'int' object is not iterable
Passing shape=(1, )
doesn't work either because it expects to have a vector as an input_var in this case:
"%d" % (ndim, input_var.ndim))
ValueError: shape has 1 dimensions, but variable has 0
The documentation does not say that you can pass an int though, only tuples of int/None
. If there's a particular passage that lead you to believe that you can pass an int, could you point it out so we can make it more clear?
For scalar input, you want to pass an empty tuple: ()
.
This is also how e.g. numpy and Theano treat scalars: as tensors with no axes.
Note that scalar input is a rather exotic use case (usually there is at least a batch dimension), so you may find that other layers end up complaining about this.