djl icon indicating copy to clipboard operation
djl copied to clipboard

Dimension mismatch or high dimensional dot operation is not supported

Open foolfish1 opened this issue 2 years ago • 2 comments
trafficstars

Code : NDManager manager = NDManager.newBaseManager(); NDArray X = manager.randomNormal(new Shape(1, 2)); NDArray trueW = manager.create(new float[]{2, -3.4f}); X.dot(trueW); Exception Dimension mismatch or high dimensional dot operation is not supported. Please use .matMul instead.

The engine is pytorch-engine and the environment is windows cpu

Thanks

foolfish1 avatar Feb 28 '23 10:02 foolfish1

@foolfish1

Can you use X.matMul(trueW)? See: https://pytorch.org/docs/stable/generated/torch.dot.html

frankfliu avatar Feb 28 '23 23:02 frankfliu

The issue can also be solved by specifying the Shape: NDArray trueW = manager.create(new float[]{2, -3.4f}, new Shape(2, 1)); But as instructed, .matMul is suggested.

KexinFeng avatar Mar 01 '23 07:03 KexinFeng