Parfor: Unable to perform assignment because the size of the left side is 98-by-50 and the size of the right side is 107-by-50

18 views (last 30 days)
Abigail Allen
Abigail Allen on 13 Apr 2020
Commented: Camila Gil on 1 Mar 2021
I have been trying to modify the speech command recognition example ( by adding in one of my own words into the data set.
However when I get to the feature extraction for the valdation set, I get the error "Unable to perform assignment because the size of the left side is 98-by-50 and the size of the right side is 107-by-50" on the line:
parfor ii = 1:numPar
I am unsure of why this section is flagging an error when my test set did this without any hiccups. Any help on this would be much appreciated, thank you!
Here is the section of code it occurs in:
% Perform the feature extraction steps described above to the validation
% set.
if ~isempty(ver('parallel'))
pool = gcp;
numPar = numpartitions(adsValidation,pool);
numPar = 1;
parfor ii = 1:numPar
subds = partition(adsValidation,numPar,ii);
XValidation = zeros(numHops,numBands,1,numel(subds.Files));
for idx = 1:numel(subds.Files)
x = read(subds);
xPadded = [zeros(floor((segmentSamples-size(x,1))/2),1);x;zeros(ceil((segmentSamples-size(x,1))/2),1)];
XValidation(:,:,:,idx) = extract(afe,xPadded);
XValidationC{ii} = XValidation;
XValidation = cat(4,XValidationC{:});
XValidation = XValidation/unNorm;
XValidation = log10(XValidation + epsil);

Accepted Answer

Edric Ellis
Edric Ellis on 14 Apr 2020
Unfortunately, error reporting from parfor has some limitations, and specifically it cannot indicate the precise line within the loop body where the error is occurring.
Having said that, I cannot see in your loop body any places where you're performing a 2-dimensional assignment operation to generate the error that you're observing... (although my guess would be the assignment into XValidation).
One option in this case is to place the entire body of your parfor loop into a separate function - that way when things do fail, you should get a more precise error location. Something like this:
parfor ii = 1:numPar
% Unfortunately, it looks like you'll need to pass through quite a number of parameters.
XValidationC{ii} = loopBodyFcn(adsValidation, numPar, ii, numHops, numBands); % more here

Sign in to comment.

More Answers (0)





Community Treasure Hunt

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

Start Hunting!