w=convnet.Layers(2).Weights;
w = mat2gray(w);
w = imresize(w, [100 100]);
figure;montage(gather(w(:,:,1,:)))
title('conv1 súlyok')

%impath=imds2.Files{33};
impath='att_faces\s16\1.pgm';
im=imread(impath);
figure;imshow(im);
imgSize = size(im);
act1 = activations(convnet,im,'conv','OutputAs','channels');
sz = size(act1);
act1 = reshape(act1,[sz(1) sz(2) 1 sz(3)]);
figure;montage(imresize(mat2gray(act1),[112,92]),'Size',[2 3])
title('conv1 aktivációs térképek')


act1Rel = activations(convnet,im,'relu','OutputAs','channels');
sz = size(act1Rel);
act1Rel = reshape(act1Rel,[sz(1) sz(2) 1 sz(3)]);
figure;montage(imresize(mat2gray(act1Rel),[112,92]),'Size',[2 3])

[maxValue,maxValueIndex] = max(max(max(act1)));
act1chMax = act1(:,:,:,maxValueIndex);
act1chMax = mat2gray(act1chMax);
act1chMax = imresize(act1chMax,[112,92]);
figure;imshowpair(imresize(im,[112,92]),act1chMax,'montage')
title('conv1 max aktiváció')

act2 = activations(convnet,im,'conv_1','OutputAs','channels');
sz = size(act2);
act2 = reshape(act2,[sz(1) sz(2) 1 sz(3)]);
figure;montage(imresize(mat2gray(act2),[112,92]),'Size',[4 5])
title('conv2 aktivációs térképek')