Theano中int32和float32的点积产生float64

The dot product of int32 and float32 produces float64 in Theano

当我编译函数时

x = theano.tensor.imatrix('x')
y = theano.tensor.fmatrix('y')
z = x.dot(y)
f = theano.function([x, y], z)

结果输出是 float64,即使 x 是 int32 类型,y 是 float32 类型。当我计算相同的操作时,其中 x 是 float32 类型的 Theano fmatrix,结果矩阵是 float32。为什么在前一种情况下不保留较小的位大小?换句话说,为什么 int32 和 float32 的点积等于 float64 而不是 Theano 中的 float32?

我正在使用 Theano 版本 0.9.0

一般来说,假设您想要保持开始时的任何精度。 int32 有 31 个有效位,选择 float32 has 24 significand bits and 8 exponent bits. Thus staying at either may cause reduced precision, and float64,它有 53 个有效位。

你也可以configure theano not to use float64 by default