代码拉取完成,页面将自动刷新
function cnnTest(cnn,images,labels)
numImages = length(images);
activations = images;
numLayers = size(cnn.layers);
for l = 1:numLayers
layer = cnn.layers{l};
if(strcmp(layer.type,'c'))%convolutional layer
activations = cnnConvolve4D(activations,layer.W,layer.b);
else
activations = cnnPool(layer.poolDim,activations);
end
layer.activations = activations;
cnn.layers{l} = layer;
end
%softmax
activations = reshape(activations,[],numImages);
probs = exp(bsxfun(@plus, cnn.Wd * activations, cnn.bd));
sumProbs = sum(probs, 1);
probs = bsxfun(@times, probs, 1 ./ sumProbs);
[~,preds] = max(probs,[],1);
preds = preds';
acc = sum(preds==labels)/length(preds);
fprintf('Accuracy is %f\n',acc);
end
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。