我正在尝试使用einsum
执行张量乘法。我在 MATLAB 中工作,但正在使用 python 接口进行调用numpy.einsum
,如本问答中所述。下面是我用来执行乘法的代码:
np = py.importlib.import_module('numpy');
ndim = 3; i = eye(ndim);
I = np.einsum('il,jk',matpy.mat2nparray(i),matpy.mat2nparray(i));
I4 = matpy.nparray2mat(...
np.einsum('ijxyz,klxyz -> ijklxyz', I, matpy.mat2nparray(ones([30,30,30])) ));
但是,上面的代码失败并出现以下错误:
ValueError: einstein sum subscripts string contains too many subscripts for operand 0