Getting transparency violation error while trying to parallel processing a code in MATLAB
古いコメントを表示
I am implementing GA in CNN. While calculating Fitness scores, i am trying to run that code on local parallel server using parfor loops but getting the error "Transparency violation error" inparfor loop.
I am sharing my code for your reference:
function scores = ga_fitness(x,convLayers,trainKidneyData,testKidneyData,imgLength,imgWidth)
% x is population size here.
persistent genNumber; % creates a variable named genNumber;
if(isempty(genNumber)) % initialize the gen number as 1 to calculate the fintess of population of generation 1.
genNumber = 1;
end
scores = zeros(size(x,1),1); %creates a matrix having dimension(popSize*1) to with Zero values. Fitness value of each network is stores in this matrix later.
parfor i=1:size(x,1) %the loop will repeat equal to the number of popSize.
%defining the layers
convConfig = x{i}; % saving the ith population of generation for which the fitness is to be calculated in convConfig.
% create the network architecture.
genConvnetConfig(convLayers,convConfig(1:convLayers),convConfig(convLayers+1:2*convLayers),imgLength,imgWidth);
run('tempScript.m');
%specify the training options
options = trainingOptions('sgdm','MaxEpochs',15,'MiniBatchSize',30,...
'InitialLearnRate',0.001,'verbose',1);
%train the network using training data
kidneyConvnet = trainNetwork(trainKidneyData,layers,options);
%classify the images using trained network
YTest = classify(kidneyConvnet,testKidneyData);
TTest = testKidneyData.Labels;
%calculate accuracy
accuracy = 100*sum(YTest == TTest)/numel(TTest);
scores(i) = accuracy;
% sscores=sscores+scores(i);
% Display the genration number, individual number, accuracy of that individual, number and size of filters in that individual network.
dispString = strcat('======Generation : ',string(genNumber),'========Individual : ',string(i),'============');
disp(dispString);
dispAccuracy = strcat('Accuracy : ', string(accuracy));
disp(dispAccuracy);
filterNumbersString = strcat('Filter Numbers = ', string(convConfig(1:convLayers)));
filterSizesString = strcat('Filter Sizes = ', string(convConfig(convLayers+1:2*convLayers)));
disp(filterNumbersString);
disp(filterSizesString);
end
Getting the error:
Error using run (line 55)
Transparency violation error.
See Parallel Computing Toolbox documentation about Transparency
Error in ga_fitness (line 9)
parfor i=1:size(x,1) %the loop will repeat equal to the number of popSize.
Please help me to fix this error
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Get Started with Statistics and Machine Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!