Classification of AlexNet deep dreams is always wrong (always nematode)

2 views (last 30 days)

I followed up the tutorial about AlexNet deep dreams and let the network dreamed about 'daisy' (index 986)

 net = alexnet;
 I = deepDreamImage(net,23,986);

Now, documentation says that image 'I' highlights the features learned by a network. I thought that this dreamed image should be classified as selected channel (daisy in my case), but it is not:

 I_resized = imresize(I,[227 227]);
 classify(net,I_resized)
 >> ans = 
    categorical 
       nematode

Moreover dreams of ALL channels are classified as 'nematode' :

net = alexnet;
%%
num_of_classes = 10;
classifications = cell(1000,num_of_classes);
scores = zeros(1000,num_of_classes);
I_dreamed = zeros(227,227,3,1000);
for class_i = 1:1000
    I = deepDreamImage(net,23,class_i);
    I_resized = imresize(I,[227 227]);% resize for classification
    I_dreamed(:,:,:,class_i) = I_resized;
      p = predict(net,I_resized);
      [p3,i3] = maxk(p,num_of_classes);%get first N classes with strongest response
      classifications(class_i,:)=net.Layers(end).ClassNames(i3);% save classes names
      scores(class_i,:) = p3; % save scores
   end

'classifications' variable is same in every row: 'nematode' 'spotlight' 'fire screen' 'stove' 'volcano' 'digital clock' 'matchstick' 'wing' 'lampshade' 'window screen'

'scores' are not same, but very similar.

(I also tried different (1000 and 10 000) 'NumIterations', and classification was still nematode )

Why isn't "daisy dream" classified as daisy? Why is everything classified as 'nematode'?

Accepted Answer

Johannes Bergstrom
Johannes Bergstrom on 22 Oct 2018
Edited: Johannes Bergstrom on 22 Oct 2018
Try setting the 'OutputScaling' value to 'none'.
By default, the deepDreamImage function scales the output pixel values in the interval [0,1], which changes the results of classification.
  1 Comment
tesarj13
tesarj13 on 23 Oct 2018
Yes. It works. Now the classification is right in 784 of 1000 cases, which is way better then just 1 nematode.

Sign in to comment.

More Answers (0)

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!