Downloads · 30 days
0
Noflowerzzk/Dl_homework
Dl_homework is a machine learning model from Noflowerzzk. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
依赖:PyTorch, timm, torchvision, scikit-learn, safetensors
Downloads · 30 days
0
Access
Public
Updated Jun 3, 2026
Repo size
1.2 GB
Likes
0
Public
Click a slice to open those files.
.pth731 MB · 59%
From the Hugging Face model README
source /opt/anaconda3/etc/profile.d/conda.sh
conda activate dl
依赖:PyTorch, timm, torchvision, scikit-learn, safetensors
| 模型 | 框架 | 预训练权重 | 输入尺寸 |
|---|---|---|---|
| ViT-B/16 | timm vit_base_patch16_224 | ImageNet-21k→1k | 224×224 |
| ResNet-18 | torchvision resnet18 | ImageNet-1k | 224×224 |
数据增强: Resize(224) → RandomCrop(224, padding=28) → RandomHorizontalFlip
标准化: CIFAR10 mean/std
优化器: AdamW (lr=1e-4, weight_decay=0.05)
学习率调度: CosineAnnealingLR
损失函数: CrossEntropyLoss
训练轮次: 10 epochs
Batch Size: 16 (ViT) / 32 (ResNet)
| 模型 | Val Top-1 | Val Top-5 |
|---|---|---|
| ViT-B/16 (pretrained) | 97.03% | 99.96% |
| ResNet-18 (pretrained) | 95.06% | 99.88% |
| ViT-B/16 (从头训练) | 32.81% | 85.37% |
# ViT 预训练模型训练
python train_vit_pretrained.py
# ResNet-18 预训练模型训练
python train_resnet.py
生成模型:models/best_vit_pretrained.pth, models/best_resnet18_pretrained.pth
本仓库已按 Hugging Face 上传结构整理大文件:
| 路径 | 说明 |
|---|---|
models/model.safetensors | ViT-B/16 原始预训练权重 |
models/best_vit_pretrained.pth | ViT-B/16 使用预训练权重后的最佳 checkpoint |
models/best_vit_base_patch16_224.pth | ViT-B/16 未预训练训练结果 |
models/best_resnet18_pretrained.pth | ResNet-18 使用预训练权重后的最佳 checkpoint |
data/cifar-10-python.tar.gz | CIFAR-10 数据集压缩包 |
上传命令:
hf auth login
hf upload Noflowerzzk/Dl_homework . . --repo-type model --exclude ".git/*" --exclude "raw_upload/*"
dl/
├── guide.md # 任务说明
├── README.md # 本文件
├── train_vit_pretrained.py # ViT训练脚本
├── train_resnet.py # ResNet训练脚本
├── eval_vit.py # ViT评估脚本
├── models/
│ ├── model.safetensors
│ ├── best_vit_pretrained.pth
│ ├── best_vit_base_patch16_224.pth
│ └── best_resnet18_pretrained.pth
└── data/
└── cifar-10-python.tar.gz