python 3.x - White spaces in Theano arrays -


i started playing around theano , got surprised result of code.

from theano import * import theano.tensor t = t.vector() out = + ** 10 f = function([a], out) print(f([0, 1, 2])) 

using python3 get:

array([    0.,     2.,  1026.]) 

the array correct, contains right values, printed output odd. expect this:

array([0, 2, 1026]) 

or

array([0.0, 2.0, 1026.0]) 

why so? white spaces? shall concerned about?

what you're printing numpy.ndarray. default format when printed.

the output array floating point array because, default, theano uses floating point tensors.

if want use integer tensors need specify dtype:

a = t.vector(dtype='int64') 

or use bit of syntactic sugar:

a = t.lvector() 

compare output output of following:

print numpy.array([0, 2, 1026], dtype=numpy.float64) print numpy.array([0, 2, 1026], dtype=numpy.int64) 

you can change default printing options of numpy using numpy.set_printoptions.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -