how to sort dlarrays

조회 수: 2 (최근 30일)
feynman feynman
feynman feynman 2022년 12월 4일
댓글: Xiaoke 2024년 9월 13일
How to sort dlarrays like in
sort(a)
, where a is a numeric array? Is there a way of sorting next(mbq) by specifying some options in the following code?
mbq = minibatchqueue(ads,MiniBatchSize=miniBatchSize,MiniBatchFormat="BC");
next(mbq)

채택된 답변

Aritra
Aritra 2023년 3월 20일
As per my understanding you are trying to sort a "dlarray" using the "sort" function.
A "dlarray" is a deep learning array designed to store data with optional data format labels for custom training loops. It also enables functions to compute and use derivatives through automatic differentiation.
However, to sort a "dlarray" you must initially convert it to a double array using the "extractdata" function. You can then use the "sort" function to sort the double array. The following code describes the same:
X = randn(1,5);
dlX = dlarray(X);
t = extractdata(dlX);
sort(t);
For detail, please see this MathWorks documentation below for more information on sorting multi-dimensional arrays: https://in.mathworks.com/help/matlab/ref/double.sortrows.html#d124e1400369
  댓글 수: 1
Xiaoke
Xiaoke 2024년 9월 13일
But this cannot be backpropagated like torch.sort, is there any solution?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Custom Training Loops에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by