format compact
p0 = [-1 1 1 1 1 -1 1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 1 1 -1 -1 -1 -1 1 -1 1 1 1 1 -1]';
%length(p0)
p1 = [-1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1]';
%length(p1)
p2 = [1 -1 -1 -1 -1 -1 1 -1 -1 1 1 1 1 -1 -1 1 -1 1 -1 1 1 -1 -1 1 -1 -1 -1 -1 -1 1]';
%length(p2)
% create my 3
p3 = [-1 -1 -1 -1 -1 -1 1 -1 1 1 -1 1 1 -1 1 1 -1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1]';
%length(p3)
p4 = [-1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 -1 1 1 1 1 1 1]';
%length(p4)
p5 = [1 1 1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 1 1 1 1]';
%length(p5)
p6 = [1 1 1 1 1 1 1 -1 1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1]';
%length(p6)
% end of create my3
% Weight calculation
target = [p0 p1 p2 p3]
pTrans = target'
myWeight = target * pTrans
% test with the weight
testingWeight = p0*p0' + p1*p1' + p2*p2' + p3*p3'
%+ p4* p4'+ p5 * p5' + p6 * p6'
% end of test
fprintf("P0 Matched Count: %d\n", doCalculate(p0, myWeight, 2))
fprintf("P1 Matched Count: %d\n", doCalculate(p1, myWeight, 2))
fprintf("p2 Matched Count: %d\n", doCalculate(p2, myWeight, 2))
fprintf("p3 Matched Count: %d\n", doCalculate(p3, myWeight, 2))
%fprintf("p4 Matched Count: %d\n", doCalculate(p4, myWeight, 6))
%fprintf("p5 Matched Count: %d\n", doCalculate(p5, myWeight, 6))
%fprintf("p6 Matched Count: %d\n", doCalculate(p6, myWeight, 6))
function count = doCalculate(inputPx, weight, numberOfPixelChange)
% inputPx is already transposed
pxSummation = weight * inputPx;
pxAxion = hardlims(pxSummation);
% set up for iteration and change pixel
counter = 0;
tempPx = inputPx;
for i = 1:10
%fprintf("Start the iteration: %d\n", i);
for j = 1:numberOfPixelChange
% change the pixel
%fprintf("Change Pixel: %d\n", j);
randomPixel = randi(30);
if tempPx(randomPixel) == 1
tempPx(randomPixel)= -1;
else
tempPx(randomPixel) = 1;
end
end
tempSummation = weight * tempPx;
tempAxion = hardlims(tempSummation);
if pxAxion == tempAxion
counter = counter + 1;
end
% reset the tempPx to original
tempPx = inputPx;
end
count = counter;
end
시발 다 수학임 ㅋㅋㅋ
뉴럴 숙제 3, 절반끝낫다ㅇㅅㅇ
무슨 언어?
메스랩 ㅇㅅㅇ
교수가 파이썬 싫어함 ㅇㅅㅇ 어짜피 대충 이론만 잘 배워놓면 파이선이던 cpp던 걍 짬 ㅇㅅㅇ
이런거 하지말고 그냥 넘파이로 구현되어있는거 하는게 낫지않나...
그거 까뒤집는거 배우는거임 ㅇㅅㅇ, 만들어진거 는 만들어진걸로 사용하고, 나중에 새로운거 만들라고 ㅇㅅㅇ