MobileNet_v1

Ann Jongmin·2025년 3월 6일

Computer vision

목록 보기
3/3

MobileNet Architecture

MobileNet에서는 일반적인 Convolution이 아닌 Depthwise Separable Convolution으로 처리한다.

Depthwise Separable Convoluntion은 depthwise convolution와 1×1 convolution called a pointwise convolution으로 이루어진다.

The combination of depthwise convolution and 1 × 1
(pointwise) convolution is called depthwise separable convolution

Standard convolution의 연산 비용:

depthwise separable convolution의 연산 비용:

결론적으로, Depthwise Separable Convolution은 표준 합성곱 대비 연산량이 훨씬 저렴하며, MobileNet 등 경량 모델이 모바일 환경에서 빠르게 동작할 수 있도록 해 주는 핵심 요소이다.

Standard convolutional layer:

Depthwise Separable convolutions (with Depthwise and Pointwise layers):


Git Repository

구현 코드 및 Training된 모델 파일은 아래 Git에 있습니다.

git clone https://github.com/MachuEngine/MobileNet_v1.git

Training 과정

Using device: cpu
Files already downloaded and verified
Files already downloaded and verified
Epoch 1: Train Loss: 1.5678, Train Acc: 0.4188
Epoch 1: Val Loss: 1.2877, Val Acc: 0.5402
Saved best model with accuracy: 0.5402
Epoch 2: Train Loss: 1.1023, Train Acc: 0.6079
Epoch 2: Val Loss: 0.9359, Val Acc: 0.6697
Saved best model with accuracy: 0.6697
Epoch 3: Train Loss: 0.8548, Train Acc: 0.6983
Epoch 3: Val Loss: 0.7417, Val Acc: 0.7369
Saved best model with accuracy: 0.7369
Epoch 4: Train Loss: 0.7007, Train Acc: 0.7575
Epoch 4: Val Loss: 0.6299, Val Acc: 0.7797
Saved best model with accuracy: 0.7797
Epoch 5: Train Loss: 0.5887, Train Acc: 0.7943
Epoch 5: Val Loss: 0.5754, Val Acc: 0.8046
Saved best model with accuracy: 0.8046
Epoch 6: Train Loss: 0.5208, Train Acc: 0.8189
Epoch 6: Val Loss: 0.5486, Val Acc: 0.8147
Saved best model with accuracy: 0.8147
Epoch 7: Train Loss: 0.4687, Train Acc: 0.8382
Epoch 7: Val Loss: 0.4860, Val Acc: 0.8331
Saved best model with accuracy: 0.8331
Epoch 8: Train Loss: 0.4197, Train Acc: 0.8555
Epoch 8: Val Loss: 0.5105, Val Acc: 0.8248
Epoch 9: Train Loss: 0.3838, Train Acc: 0.8688
Epoch 9: Val Loss: 0.4377, Val Acc: 0.8497
Saved best model with accuracy: 0.8497
Epoch 10: Train Loss: 0.3484, Train Acc: 0.8784
Epoch 10: Val Loss: 0.4534, Val Acc: 0.8448
Training complete. Best validation accuracy: 0.8497

Predict 과정

Input image

CIFAR-10 데이터셋의 클래스

라벨(Index)클래스 이름(Class Name)
0airplane
1automobile
2bird
3cat
4deer
5dog
6frog
7horse
8ship
9truck

예측 결과: 확률 기반 top 5

1-best가 클래스 4인 사슴으로 예측 확인

FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
  model.load_state_dict(torch.load('./models/best_model.pth', map_location=torch.device('cpu')))
  
Top 5 예측 결과:
클래스 4: 확률 0.9937
클래스 2: 확률 0.0058
클래스 5: 확률 0.0003
클래스 0: 확률 0.0001
클래스 3: 확률 0.0001
profile
AI Study

0개의 댓글