【深圳大學機器學習】實驗一:PCA算法

實驗目的

1、實現PCA算法的人臉重構,即用20,40,60,80,...,160個投影來重構圖像的效果。

2、實現PCA算法的人臉識別,給出不少于三個人臉數據庫上 10,20,30,...,160維的人臉識別識別率,并打印出識別率變化曲線圖。

3、用PCA用來進行人臉圖像降維,實現3個不同數據集多個子集(或多個類)的二維和三維空間實現數據的可視化,不同類用不同顏色表示。

4、比較PCA、2DPCA、B2PCA在各個人臉數據集上的最高識別率,比較重構圖像的差異。

實驗步驟:

一,基于PCA算法的人臉重構與人臉識別,以及數據可視化

1,(條件:基于AR數據集的前120人,每人取前三張圖像作為訓練數據,后七張作為識別數據)

原圖

不同維度下的重構效果(AR001-1.tif)

維度

正確率

20

62.70%

40

68.52%

60

71.33%

80

74.27%

100

74.53%

120

75.20%

140

75.41%

160

75.89%

取用不同數量特征值和正確率??????? 基于此情況下人臉識別識別率曲線

數據可視化

???????????? 二維空間?????????????????????? 三維空間

2,(條件:基于orl數據集的前40人,每人取前三張圖像作為訓練數據,后七張作為識別數據)

原圖

不同維度下重構效果(orl1_1.bmp)

維度

正確率

20

78.92%

40

83.57%

60

85.00%

80

85.71%

100

86.42%

120

86.07%

140

86.07%

160

86.07%

取用不同數量特征值和正確率??????? 基于此情況下人臉識別識別率曲線?????? ???

數據可視化

二維空間?????????????????????? 三維空間

3,(條件:基于Yale數據集的前15人,每人取前三張圖像作為訓練數據,后七張作為識別數據)

原圖

不同維度下重構效果(subject01_1.bmp)

維度

正確率

20

87.73%

40

86.77%

60

86.77%

80

86.77%

100

86.77%

120

86.77%

140

86.77%

160

86.77%

取用不同數量特征值和正確率???????? 基于此情況下人臉識別識別率曲線

數據可視化

???????????? 二維空間?????????????????????? 三維空間

二,PCA,2DPCA,B2DPCA重構圖像與識別率差異

條件:在ORL數據集上的重構效果(40個人,取前六張訓練,后四張識別的情況下展示重構效果)

重構效果:

原圖

PCA:

2DPCA:

B2DPCA

識別正確率(orl數據集,40個人,前六張訓練,后四張識別):

PCA:

最高正確率為96.3%

2DPCA:

最高正確率為97.5%

B2DPCA:

最高正確率為97.5%

嘗試不同訓練圖像與識別圖像比例后結果如下:

訓練情況

訓練3,識別7

訓練4,識別6

訓練5,識別5

訓練6,識別4

訓練7,識別3

PCA

86.4%

89.6%

90.0%

96.3%

96.7%

2DPCA

93.2%

93.3%

93.5%

97.5%

97.5%

B2DPCA

93.2%

93.3%

93.5%

97.5%

97.5%

從表中可以知道,2DPCA和B2DPCA在ORL訓練集上的最高正確率基本相同,高于PCA的正確率,同時隨著訓練數據的增加,PCA與它們識別正確率的差距逐漸減小。

進一步發現,在訓練圖像6張,識別圖像四張的情況下,PCA,2DPCA,B2DPCA識別時間如下:

PCA

2DPCA

B2DPCA

4.09s

1.59s

1.22s

可以看出,2DPCA和B2DPCA雖然在正確率上差別不大,但B2DPCA卻比2DPCA更加節省時間,二者所耗時間均遠遠小于傳統PCA算法。

代碼:

PCA:

%1,測試與訓練圖像的錄入(附加計時以查看效率)
tic
reshaped_faces=[];
%訓練圖像讀取(以orl為例)
for i=1:40for j=1:10 a=imread(strcat('C:\Users\18023\Desktop\粵海小清華\homework\計導文件\人臉數據庫\ORL56_46\orl',num2str(i),'_',num2str(j),'.bmp'));     b = reshape(a,2576,1); %將每一張人臉拉成列向量b=double(b); %uint-8轉換為double類型,避免人臉展示時全灰的影響       reshaped_faces=[reshaped_faces, b];  %儲存每一列轉化后的列向量到矩陣reshaped_faces中end
end%用每個人前六張作為訓練圖,后四張作為測試圖
%初始化測試集集矩陣
test_data_index = [];
%初始化訓練集矩陣
train_data_index = [];  
for k=0:(size(reshaped_faces,2)/j)-1train_data_index= [train_data_index j*k+1:j*k+3];%建立一個用于查找所需訓練圖像的目錄test_data_index= [test_data_index j*k+4:j*(k+1)];%同理,是測試圖像的目錄
end
train_data = reshaped_faces(:,train_data_index);%根據index讀取矩陣 reshaped_faces的數據添加到矩陣train_data中
test_data = reshaped_faces(:, test_data_index);%根據index1讀取矩陣 reshaped_faces的數據添加到矩陣test_data中% 2-特征向量矩陣(all_eigen_face)求得過程
% 求平均臉
mean_face = mean(train_data,2);%用mean函數求訓練集矩陣的平均值,2是對每一行求平均,最后得到一個和原先尺寸一樣的一個人臉,每個像素是平均顏色
% 中心化
normalizeddata= (train_data - mean_face);%得到中心化人臉(此處減去一列等于traindata每一列都減去這一列) 
%PCA特征值分解的矩陣為去中心化的矩陣乘其轉置矩陣
cov= normalizeddata * normalizeddata';
%特征值分解
[eigen_vectors, eigenvalues] = eig(cov);
% 從對角矩陣獲取特征值
eigen_values = diag(eigenvalues);
% 對特征值按索引進行從大到小排序
[sorted_eigen_values, index] = sort(eigen_values, 'descend'); %此處建立index獲取特征值的位置,以便尋找對應的特征向量
%按照特征值的大小排列特征向量
sorted_eigen_vectors = eigen_vectors(:, index);
all_eigen_faces = sorted_eigen_vectors;%2重構過程
single_face = normalizeddata(:,1);%代碼中取第一張臉進行重構
index = 1;
figure;
for dim=[20,40,60,80,100,120,140,160]eigen_faces = all_eigen_faces(:,1:dim);%降維與再次重構rebuild_face = eigen_faces * (eigen_faces' * single_face) + mean_face;subplot(2,4, index); index = index + 1;fig = imshow(mat2gray(reshape(rebuild_face, [56, 46])));title(sprintf("維度=%d", dim));    if (dim == 160)waitfor(fig);end
end% 3.人臉識別
index = 1;       
k = length(10:10:160);  %選取適當間隔
Y = zeros(1, k); 
% 遍歷每個維度
for i = 1:kd = 10 * i;  % 通過i確定當前維度% 取出相應數量特征向量eigen_faces = all_eigen_faces(:, 1:d);% 測試、訓練數據降維projected_train_data = eigen_faces' * (train_data - mean_face);projected_test_data = eigen_faces' * (test_data - mean_face);% 測試前準備過程correct_predict_number = 0;test_face_number = size(projected_test_data, 2);% 讀取測試數據與初始化for each_test_face_index = 1:test_face_numbereach_test_face = projected_test_data(:, each_test_face_index);% 初始化最小距離min_distance = inf;predicted_label = -1;%在歐氏距離下與每一個降維后的數據進行比較for each_train_face_index = 1:size(projected_train_data, 2)% 計算距離distance = norm(each_test_face - projected_train_data(:, each_train_face_index));% 如果當前距離小于之前的最小距離,則更新最小距離和標簽(1NN,取最近的一個)if distance < min_distancemin_distance = distance;predicted_label = floor((train_data_index(1, each_train_face_index) - 1) / j) + 1;endend% 獲取該數據真實的標簽real_label = floor((test_data_index(1, each_test_face_index) - 1) / j) + 1;% 判斷預測結果是否正確if predicted_label == real_labelcorrect_predict_number = correct_predict_number + 1; % 如果預測正確,增加正確數endend % 計算正確率correct_rate = correct_predict_number / test_face_number;% 將當前維度對應的正確率存入YY(i) = correct_rate;  % 使用索引i來存儲正確率,確保Y與d一致% 輸出當前實驗結果fprintf("維度=%d,總測試樣本:%d,正確數:%d,正確率:%1f\n", d, test_face_number, correct_predict_number, correct_rate);
end
toc% 4,制作折線圖使正確率隨維度變化可視化
figure;
plot(10:10:160, Y, '-o');  % x軸為維度數,y軸為正確率
xlabel('維度數');
ylabel('正確率');
title('人臉識別正確率與維度變化');
waitfor(fig);%5,散點圖繪制
for t=[2 3]eigen_faces=all_eigen_faces(:,1:t);projected_test_data=eigen_faces'*(test_data - mean_face);color=[];for x=1:size(test_data,2)color=[color floor((x-1)/19*2)];endif (t == 2)waitfor(scatter(projected_test_data(1, :), projected_test_data(2, :), [], color));elsewaitfor(scatter3(projected_test_data(1, :), projected_test_data(2, :), projected_test_data(3, :), [], color));endend

2DPCA

%1,測試與訓練圖像的錄入
tic
reshaped_faces=[];
%訓練圖像讀取(以orl為例)
for i=1:40for j=1:10%a=imread(strcat('C:\Users\18023\Desktop\粵海小清華\homework\計導文件\人臉數據庫\ORL56_46\orl',num2str(i),'_',num2str(j),'.bmp'));     b = reshape(a,2576,1); b=double(b);       reshaped_faces=[reshaped_faces, b]; end
end%用每個人前六張作為訓練圖,后四張作為測試圖
%定義測試集集矩陣
test_data_index = [];
%定義訓練集矩陣
train_data_index = [];  
for k=0:(size(reshaped_faces,2)/j)-1train_data_index= [train_data_index j*k+1:j*k+6];%建立一個用于查找所需訓練圖像的目錄test_data_index= [test_data_index j*k+7:j*(k+1)];%同理,是測試圖像的目錄
end
train_data = reshaped_faces(:,train_data_index);%讀取矩陣 reshaped_faces的數據添加到矩陣train_data中
test_data = reshaped_faces(:, test_data_index);%讀取矩陣 reshaped_faces的數據添加到矩陣test_data中
mean_face = mean(train_data,2);%2,2DPCA矩陣求取
%對于訓練矩陣重新還原成二維疊加的狀態
train_matrices = cell(size(train_data, 2), 1);
for i = 1:size(train_data, 2)train_matrices{i} = reshape(train_data(:, i), [56, 46]);
end
%所有訓練圖像矩陣的均值
mean_face_matrix = zeros(56, 46);
for i = 1:length(train_matrices)mean_face_matrix = mean_face_matrix + train_matrices{i};
end
mean_face_matrix = mean_face_matrix / length(train_matrices);% 初始化2DPCA協方差矩陣
cov_2dpca = zeros(46, 46);  
% 計算2DPCA的協方差矩陣
for i = 1:length(train_matrices)centered_matrix = train_matrices{i} - mean_face_matrix;%每一個二維數據進行去中心化cov_contribution = centered_matrix' * centered_matrix;%求取其協方差矩陣cov_2dpca = cov_2dpca + cov_contribution;%每一個二維數據的協方差矩陣,都加到最后求解的矩陣上
end
cov_2dpca = cov_2dpca / length(train_matrices);%除以所有參與的二維矩陣數,求得均值
%cov_2dpca即為最終進行協方差分解的矩陣
%特征值分解與按照特征值從大到小排列
[eigen_vectors, eigenvalues] = eig(cov_2dpca);
eigen_values = diag(eigenvalues);
[sorted_eigen_values, index] = sort(eigen_values, 'descend');
sorted_eigen_vectors = eigen_vectors(:, index);
all_eigen_faces = sorted_eigen_vectors;figure
% 3,計算重構過程,展示第一張訓練圖像的重構
for idx = 1:4dim = idx * 10;eigen_faces = all_eigen_faces(:, 1:dim);  % 選擇前dim個特征向量% 計算投影系數test_image = train_matrices{1};  % 獲取第一張訓練圖像centered_image = test_image - mean_face_matrix;  % 中心化圖像projection = centered_image * eigen_faces;  % 投影到特征空間% 重構圖像rebuild_face = mean_face_matrix + (projection * eigen_faces');  % 重構% 顯示重構結果subplot(1, 4, idx);imshow(mat2gray(rebuild_face));  % 顯示重構圖像title(sprintf('維度=%d', dim));
end% 4.人臉識別
index = 1;       
k = length(10:10:40);
Y = zeros(1, k);
% 將測試圖像轉換為矩陣形式
test_matrices = cell(size(test_data, 2), 1);
for i = 1:size(test_data, 2)test_matrices{i} = reshape(test_data(:, i), [56, 46]);
end
% 遍歷每個維度
for i = 1:kd = 10* i;% 取出相應數量特征向量projection_vectors = all_eigen_faces(:, 1:d);% 計算訓練和測試圖像的特征train_features = zeros(size(train_data, 2), 56*d);test_features = zeros(size(test_data, 2), 56*d);% 對每張訓練圖像進行投影for j = 1:length(train_matrices)% 計算投影projected = train_matrices{j} * projection_vectors; % 56×d% 將投影結果展平為特征向量train_features(j, :) = projected(:)';end% 對每張測試圖像進行投影for j = 1:length(test_matrices)projected = test_matrices{j} * projection_vectors;test_features(j, :) = projected(:)';end% 測試前準備過程correct_predict_number = 0;test_face_number = size(test_features, 1);% 遍歷每一個待測試人臉for each_test_face_index = 1:test_face_numbereach_test_face = test_features(each_test_face_index, :)'; % 讀取測試用的臉特征% 初始化最小距離min_distance = inf;predicted_label = -1;% 對比每一張訓練臉for each_train_face_index = 1:size(train_features, 1)% 計算距離distance = norm(each_test_face - train_features(each_train_face_index, :)');% 如果當前距離小于之前的最小距離,則更新最小距離和標簽if distance < min_distancemin_distance = distance;predicted_label = floor((train_data_index(1, each_train_face_index) - 1) / j) + 1;endend% 獲取實際標簽real_label = floor((test_data_index(1, each_test_face_index) - 1) / j) + 1;% 判斷預測結果是否正確if predicted_label == real_labelcorrect_predict_number = correct_predict_number + 1;endend% 計算正確率correct_rate = correct_predict_number / test_face_number;Y(i) = correct_rate;fprintf("維度=%d,總測試樣本:%d,正確數:%d,正確率:%1f\n", d, test_face_number, correct_predict_number, correct_rate);
end
toc% 制作折線圖使正確率隨維度變化可視化
figure;
plot(10:10:40, Y, '-o');  % x軸為維度數,y軸為正確率
xlabel('維度數');
ylabel('正確率');
title('人臉識別正確率與維度變化');

B2DPCA

%1,測試與訓練圖像的錄入
tic
reshaped_faces=[];
for i=1:40for j=1:10 a=imread(strcat('C:\Users\18023\Desktop\粵海小清華\homework\計導文件\人臉數據庫\ORL56_46\orl',num2str(i),'_',num2str(j),'.bmp'));     b = reshape(a,2576,1); b=double(b);     reshaped_faces=[reshaped_faces, b];  end
end%用每個人前六張作為訓練圖,后四張作為測試圖
%定義測試集集矩陣
test_data_index = [];
%定義訓練集矩陣
train_data_index = [];  
for k=0:(size(reshaped_faces,2)/j)-1train_data_index= [train_data_index j*k+1:j*k+6];%建立一個用于查找所需訓練圖像的目錄test_data_index= [test_data_index j*k+7:j*(k+1)];%同理,是測試圖像的目錄
end
train_data = reshaped_faces(:,train_data_index);%讀取矩陣 reshaped_faces的數據添加到矩陣train_data中
test_data = reshaped_faces(:, test_data_index);%讀取矩陣 reshaped_faces的數據添加到矩陣test_data中
mean_face = mean(train_data,2);%2,協方差矩陣求取
%對于訓練矩陣重新還原成二維疊加的狀態
train_matrices = cell(size(train_data, 2), 1);
for i = 1:size(train_data, 2)train_matrices{i} = reshape(train_data(:, i), [56, 46]);
end%求所有訓練圖像矩陣的均值
mean_face_matrix = zeros(56, 46);
for i = 1:length(train_matrices)mean_face_matrix = mean_face_matrix + train_matrices{i};
end
mean_face_matrix = mean_face_matrix / length(train_matrices);% 行和列方向特征值分解
%行方向
cov_2dpca_col = zeros(46, 46);
for i = 1:length(train_matrices)centered_matrix = train_matrices{i} - mean_face_matrix;%求得每一個二維數據去中心化的結果cov_contribution = centered_matrix' * centered_matrix;%行方向協方差矩陣求解,用轉置乘以原矩陣cov_2dpca_col = cov_2dpca_col + cov_contribution;
end
cov_2dpca_col = cov_2dpca_col / length(train_matrices);
%列方向
cov_2dpca_row = zeros(56, 56);
for i = 1:length(train_matrices)centered_matrix = train_matrices{i} - mean_face_matrix;%求得每一個二維數據去中心化的結果cov_contribution = centered_matrix * centered_matrix';%列方向協方差矩陣求解,用原矩陣乘以其轉置cov_2dpca_row = cov_2dpca_row + cov_contribution;
end
cov_2dpca_row = cov_2dpca_row / length(train_matrices);% 列方向特征向量求取
[eigen_vectors_col, eigenvalues_col] = eig(cov_2dpca_col);
eigen_values_col = diag(eigenvalues_col);
[sorted_eigen_values_col, index_col] = sort(eigen_values_col, 'descend');
sorted_eigen_vectors_col = eigen_vectors_col(:, index_col);% 行方向特征向量求取
[eigen_vectors_row, eigenvalues_row] = eig(cov_2dpca_row);
eigen_values_row = diag(eigenvalues_row);
[sorted_eigen_values_row, index_row] = sort(eigen_values_row, 'descend');
sorted_eigen_vectors_row = eigen_vectors_row(:, index_row);%3,人臉重構查看效果
figure;
for idx = 1:8dim_col = idx * 5;  % 列方向降維dim_row = idx * 5;  % 行方向降維% 行和列方向特征向量選取eigen_faces_col = sorted_eigen_vectors_col(:, 1:dim_col);eigen_faces_row = sorted_eigen_vectors_row(:, 1:dim_row);% 獲取第一張訓練圖像并重構test_image = train_matrices{1};centered_image = test_image - mean_face_matrix;% B2DPCA投影和重構projection = eigen_faces_row' * centered_image * eigen_faces_col;rebuild_face = mean_face_matrix + eigen_faces_row * projection * eigen_faces_col';% 顯示重構結果subplot(2, 4, idx);imshow(mat2gray(rebuild_face));title(sprintf('維度=%d×%d', dim_row, dim_col));
end%4,人臉識別部分
index = 1;       
k = length(10:10:40);
Y = zeros(1, k);% 將測試圖像轉換為矩陣形式
test_matrices = cell(size(test_data, 2), 1);
for i = 1:size(test_data, 2)test_matrices{i} = reshape(test_data(:, i), [56, 46]);
end% 遍歷每個維度
for i = 1:kd = 10 * i;  % 每個方向的維度% 取出特征向量projection_vectors_col = sorted_eigen_vectors_col(:, 1:d);projection_vectors_row = sorted_eigen_vectors_row(:, 1:d);% 計算訓練和測試圖像的特征train_features = zeros(size(train_data, 2), d * d);test_features = zeros(size(test_data, 2), d * d);% 對每張訓練圖像進行雙向投影for j = 1:length(train_matrices)centered_matrix = train_matrices{j} - mean_face_matrix;projected = projection_vectors_row' * centered_matrix * projection_vectors_col;train_features(j, :) = projected(:)';end% 對每張測試圖像進行雙向投影for j = 1:length(test_matrices)centered_matrix = test_matrices{j} - mean_face_matrix;projected = projection_vectors_row' * centered_matrix * projection_vectors_col;test_features(j, :) = projected(:)';end% 測試前準備過程correct_predict_number = 0;test_face_number = size(test_features, 1);% 遍歷每一個待測試人臉for each_test_face_index = 1:test_face_numbereach_test_face = test_features(each_test_face_index, :)'; % 讀取測試用的臉特征% 初始化最小距離min_distance = inf;predicted_label = -1;% 對比每一張訓練臉for each_train_face_index = 1:size(train_features, 1)% 計算距離distance = norm(each_test_face - train_features(each_train_face_index, :)');% 如果當前距離小于之前的最小距離,則更新最小距離和標簽if distance < min_distancemin_distance = distance;predicted_label = floor((train_data_index(1, each_train_face_index) - 1) / j) + 1;endend% 獲取實際標簽real_label = floor((test_data_index(1, each_test_face_index) - 1) / j) + 1;% 判斷預測結果是否正確if predicted_label == real_labelcorrect_predict_number = correct_predict_number + 1;endend% 計算正確率correct_rate = correct_predict_number / test_face_number;Y(i) = correct_rate;fprintf("維度=%d,總測試樣本:%d,正確數:%d,正確率:%1f\n", d, test_face_number, correct_predict_number, correct_rate);
end
toc% 制作折線圖使正確率隨維度變化可視化
figure;
plot(10:10:40, Y, '-o');  % x軸為維度數,y軸為正確率
xlabel('維度數');
ylabel('正確率');
title('人臉識別正確率與維度變化');

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/pingmian/87587.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/87587.shtml
英文地址,請注明出處:http://en.pswp.cn/pingmian/87587.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

編程中的英語

case this are mixed case version case在這里表示大小寫&#xff1f;為什么case可以表示大小寫的含義&#xff1f; “case”在這里的含義 在句子“This are mixed case version”中&#xff0c;“case”確實表示“大小寫”&#xff0c;用于描述字母的形式&#xff08;大寫字母…

LabVIEW開發關節軸承試驗機

LabVIEW通過NI硬件&#xff08;CompactRIO 實時控制器、FPGA 模塊等&#xff09;與模塊化軟件設計的結合&#xff0c;實現試驗參數采集、多工況控制、數據存儲的并行處理&#xff0c;體現LabVIEW 在工業自動化中對多任務并發場景的高效支持能力。 ? 應用場景 關節軸承試驗機…

【Linux庖丁解牛】— 動靜態庫的制作和使用!

1. 什么是庫庫是寫好的現有的&#xff0c;成熟的&#xff0c;可以復?的代碼。現實中每個程序都要依賴很多基礎的底層庫&#xff0c;不可能 每個?的代碼都從零開始&#xff0c;因此庫的存在意義?同尋常。 本質上來說庫是?種可執?代碼的?進制形式&#xff0c;可以被操作系統…

Hadoop集群啟動 (ZooKeeper、HDFS、YARN、Hbase)

一、啟動ZooKeeper集群 sh /opt/modules/zookeeper-3.4.14/bin/zkServer.sh start[hadoopcentos01 ~]$ sh /opt/modules/zookeeper-3.4.14/bin/zkServer.sh start ZooKeeper JMX enabled by default Using config: /opt/modules/zookeeper-3.4.14/bin/../conf/zoo.cfg Startin…

React Hooks全面解析:從基礎到高級的實用指南

React Hooks全面解析&#xff1a;從基礎到高級的實用指南 React Hooks自2018年16.8版本引入以來&#xff0c;徹底改變了React組件的開發方式。** Hooks使函數組件獲得了與類組件同等的表達能力&#xff0c;同時簡化了代碼結構&#xff0c;提升了可維護性**。本文將系統介紹Rea…

LINUX75 LAMP

LAMP 環境 yum NetworkManager systemctl status firewalld setenforce 0 Last login: Fri Jul 4 19:21:47 2025 from 192.168.235.1 [rootweb ~]# cd /usr/local/apache2/conf/ [rootweb conf]# ls extra httpd.conf httpd.conf.bak magic mime.types original [root…

cloudflare配合github搭建免費開源影視LibreTV一個獨享視頻網站 詳細教程

一、項目簡介 LibreTV 是一個開源的 IPTV/影視聚合前端項目&#xff0c;支持 M3U 播放列表、EPG 電子節目單等。它本身是純前端項目&#xff0c;非常適合用 GitHub Pages Cloudflare 免費托管。 二、準備工作 GitHub 賬號 注冊并登錄 GitHub Cloudflare 賬號 注冊并登錄 …

Linux/Unix進程概念及基本操作(PID、內存布局、虛擬內存、環境變量、fork、exit、wait、exec、system)

進程 文章目錄 進程I 進程基本概念1、進程和程序2、進程號和父進程號3、進程內存布局4、虛擬內存管理&#xff08;1&#xff09;程序的兩種局部性&#xff08;2&#xff09;虛擬內存的規劃&#xff08;3&#xff09;虛擬內存的優點 5、棧和棧幀6、命令行參數argc和argv7、環境變…

0基礎學Python系列【25】 單元測試入門教程

大家好,歡迎來到Python學習的第三站!?? 這部分會涉及一些Python的進階技術,雖然不一定是必需的,但學會這些,你會覺得編程更得心應手。 本章要學什么? Python調試器(pdb)裝飾器lambda函數代碼性能分析單元測試入門 —— 今天講這里聽起來有點多?別擔心,我們慢慢來,…

iOS常見內存錯誤碼

一、經典十六進制錯誤碼0xDEADBEEF&#xff08;EXC_BAD_ACCESS&#xff09; 含義&#xff1a;野指針訪問&#xff08;訪問已釋放的內存地址&#xff09;。 記憶點&#xff1a;“DEAD BEEF” 可理解為 “死亡牛肉”&#xff0c;象征指針指向的內存已 “死亡”。 觸發場景&#x…

CSS01:CSS的快速入門及優勢

CSS快速入門 style 練習格式&#xff1a; <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><title>CSS</title><!-- 規范,<style>可以編寫css代碼,每一個聲明最好用分號結尾語法&#xff1a;…

springsecurity5配置之后啟動項目報錯:authenticationManager cannot be null

目錄 配置代碼 報錯信息 解決辦法 配置代碼 下面的配置為響應式的配置方式 //這個配置只是配置springboot admin的一個例子,具體的配置可能比較復雜 @EnableWebFluxSecurity public class SecurityConfig {private final AdminServerProperties adminServer;public Securi…

攻防世界-Rerverse-game

知識點 1.ida逆向 2.函數分析逆向 步驟 用Exeinfo打開&#xff0c;為32位exe文件。 方法一&#xff1a; 玩游戲通關&#xff0c;根據游戲規則&#xff0c;m1&#xff0c;n依次為1到8即可得到flag。 方法二&#xff1a; 用32位IDA打開 ctrlF搜索main&#xff0c;點擊_main,…

openEuler 24.03 全流程實戰:用 Ansible 5 分鐘部署分布式 MinIO 高可用集群

目錄 0 | 為什么要寫這篇教程&#xff1f; 1 | 準備工作 1.1 控制節點手工下載 MinIO 1.2 SSH 互信&#xff08;可跳過&#xff0c;本教程已有互信&#xff09; 1.3 安裝 Ansible & SELinux 依賴 2 | 項目目錄 3 | Inventory hosts.ini 4 | 變量文件 group_vars/al…

最左匹配原則

導讀&#xff1a; 首先創建一張 test 表&#xff0c;并插入一些數據&#xff1a; CREATE TABLE test ( id int(11) NOT NULL AUTO_INCREMENT COMMENT 主鍵, a int(11) NOT NULL, b int(11) NOT NULL, c int(11) NOT NULL, d int(11) NOT NULL, PRIMARY KEY (id), KEY idx_abc …

MySQL 8.0 OCP 1Z0-908 題目解析(17)

題目65 Choose two. Which two are characteristics of snapshot-based backups? □ A) The frozen file system can be cloned to another virtual machine immediately into active service. □ B) There is no need for InnoDB tables to perform its own recovery when re…

Level2_12小球與擋板(移動+反彈)

一、前引 #已經學習完了: #1.數據結構&#xff1a;集合、元組、字典 #2.函數 #3.類和對象 #4.繼承與多態 #1.規劃編程項目: #&#xff08;1&#xff09;你想做什么什么樣功能的項目&#xff1f; # 接小球游戲,碰到擋板時自動反彈 #&#xff08;2&#xff09;功能有哪些&#x…

win11 2025開機禁用微軟賬號登錄,改本地用戶登錄,品牌預裝機福音

今天開箱了品牌商出廠系統一臺華為筆記本&#xff0c;開機提示連接wifi并需要登錄微軟賬號&#xff0c;其中過程實在緩慢&#xff0c;而且老是提示自動更新&#xff0c;速度太慢了&#xff0c;等的花都謝了&#xff0c;進到桌面大概得要30-40分鐘&#xff0c;還不如本地用戶登錄…

【嵌入式ARM匯編基礎】-ELF文件格式內部結構詳解(三)

ELF文件格式內部結構詳解(三) 文章目錄 ELF文件格式內部結構詳解(三)12、動態部分和動態加載13、依賴加載(需要)14、程序重定位14.1 靜態重定位14.2 動態重定位14.3 全局偏移表 (GOT)14.4 過程鏈接表 (PLT)12、動態部分和動態加載 ELF 文件格式中的 .dynamic 部分用于指…

HTML知識復習2

文章目錄 HTML5簡介什么是HTML5HTML5優勢 新增語義化標簽新增布局標簽新增狀態標簽新增列表標簽新增文本標簽 新增表單功能表單控件新增屬性input新增屬性值 新增多媒體標簽視頻標簽音頻標簽 HTML5兼容性處理 HTML5簡介 什么是HTML5 HTML5 是新一代的 HTML 標準&#xff0c;2…