我有一个矩阵和3D张量定义如下:
import numpy as np
import theano
import theano.tensor as T
a = T.matrix('a', dtype='float32')
c = T.tensor3('c',dtype='float32')
d = T.batched_dot(c, a)
g = theano.function([a,c],d)
Y = [[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 0]], [[0, 0 ,0, 0], [0, 1, 0, 0],[0, 0, 1, 0],[0, 0, 0, 1]]]
X = [[ 0.5052417 , 0.22012063, 0.21787818, 0.41821062, 1, 1, 1, 0], [ 0.48668074, 0.26137591, 0.240702 , 0.41308364, 0, 1, 1, 1]]
x = np.array(X, dtype='float32')
y = np.array(Y, dtype='float32')
print g(x[:,0:4], y)
虽然它最终给出了正确的答案,但在中间它显示了许多错误
ValueError: get_scalar_constant_value detected deterministic IndexError: x.shape[2] when x.ndim=2. x=Subtensor{int64}.0
ERROR (theano.gof.opt): Optimization failure due to: local_gpua_gemmbatch
ERROR (theano.gof.opt): node: BatchedDot(c, a)
ERROR (theano.gof.opt): TRACEBACK:
ValueError: get_scalar_constant_value detected deterministic IndexError: x.shape[2] when x.ndim=2. x=Subtensor{int64}.0
我的预期输出是
[[ 0.50524169 0.22012062 0.21787818 0. ]
[ 0. 0.2613759 0.240702 0.41308364]]
我怎样才能正确地将这两者相乘?