How can we compute batch matrix-matrix product of matrices (3-D tensors) in MATLAB?
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
BIPIN SAMUEL
el 5 de Dic. de 2023
Comentada: BIPIN SAMUEL
el 7 de Dic. de 2023
I have two 3-D tensors of size b*n*m and b*m*p. I need the product of these two tensors to get the output size as b*n*p. I have used direct matrix multiplication using * operator. Moreover, I have used 'pagetimes'. But it is not working. Is there any function in MATLAB like 'torch.bmm' in python as shown in link: https://pytorch.org/docs/stable/generated/torch.bmm.html to do the matrix multiplication of two 3-D tensors.
0 comentarios
Respuesta aceptada
Bruno Luong
el 5 de Dic. de 2023
b = 2;
n = 3;
m = 4;
p = 5;
A = rand(b,n,m);
B = rand(b, m,p);
AA = permute(A, [2 3 1]);
BB = permute(B, [2 4 1 3]);
AB=pagemtimes(AA, BB);
AB=permute(AB,[3 1 4 2]);
size(AB)
AB
5 comentarios
Bruno Luong
el 6 de Dic. de 2023
Sorry I don't know dlarray, and I'm not sure what layer do you refer to.
Más respuestas (0)
Ver también
Categorías
Más información sobre Pattern Recognition and Classification en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!