python - Why does theano conv2d add empty dimension? -


i playing around simple theano code, , ran following:

import numpy import theano theano import tensor theano.tensor.signal.conv import conv2d  m = tensor.fmatrix() w = numpy.ones([10,1], dtype=numpy.float32) c = conv2d(m,w) f = theano.function([m], c) print f(numpy.ones([100,100], dtype=numpy.float32)).shape 

result: (1, 91, 100)

the result of 2d convolution of 2d inputs expected 2d, 3d. why?

the docstring of conv2d says signal.conv.conv2d performs basic 2d convolution of input given filters. (note plural)

you pass several filters , return convolutions of those. try e.g.

c = conv2d(m,np.array([w, w, w])) f = theano.function([m], c) print f(numpy.ones([100,100], dtype=numpy.float32)).shape  # outputs (3, 91, 100) 

so seems default add degenerate axis if pass 1 filter (probably because adds axis internally filter if didn't pass in way yourself. in other words, doesn't keep track of input shape in order return corresponds. looks design choice more else.)


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -