我正在尝试使用einsum
执行张量乘法。我正在使用MATLAB,但是正在使用python接口调用this Q&A中所述的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