pytorch常见工具箱
收集整理了一些常见的可以用到的深度学习网址、工具
1. 预训练模型
https://github.com/Cadene/pretrained-models.pytorch
https://github.com/rwightman/pytorch-image-models
https://github.com/welkin-feng/ComputerVision
2. 数据增强
https://github.com/albumentations-team/albumentations
3. 标记工具
Labelme: Image Polygonal Annotation with Python
LabelImg:LabelImg is a graphical image annotation tool and label object bounding boxes in images
4. 数据集查找
! ! ! You can find datasets in Paper Beachmark
UCI Machine Learning Repository.
Government Datasets: EU US NZL IND
5. 模型分析工具
(1) 卷积层输出大小计算
https://ezyang.github.io/convolution-visualizer/index.html
(2) 计算模型参数量
https://github.com/sksq96/pytorch-summary
(3) 模型可视化工具
Netron: now supports ONNX, Keras, CoreML, Caffe2, Mxnet, Pytorch and Tensorflow.
Graphviz: Pytorch
6. 可视化工具
# Example using Visdom.
vis = visdom.Visdom(env='Learning curve', use_incoming_socket=False)
assert self._visdom.check_connection()
self._visdom.close()
options = collections.namedtuple('Options', ['loss', 'acc', 'lr'])(
loss={'xlabel': 'Epoch', 'ylabel': 'Loss', 'showlegend': True},
acc={'xlabel': 'Epoch', 'ylabel': 'Accuracy', 'showlegend': True},
lr={'xlabel': 'Epoch', 'ylabel': 'Learning rate', 'showlegend': True})
for t in epoch(80):
tran(...)
val(...)
vis.line(X=torch.Tensor([t + 1]), Y=torch.Tensor([train_loss]),
name='train', win='Loss', update='append', opts=options.loss)
vis.line(X=torch.Tensor([t + 1]), Y=torch.Tensor([val_loss]),
name='val', win='Loss', update='append', opts=options.loss)
vis.line(X=torch.Tensor([t + 1]), Y=torch.Tensor([train_acc]),
name='train', win='Accuracy', update='append', opts=options.acc)
vis.line(X=torch.Tensor([t + 1]), Y=torch.Tensor([val_acc]),
name='val', win='Accuracy', update='append', opts=options.acc)
vis.line(X=torch.Tensor([t + 1]), Y=torch.Tensor([lr]),
win='Learning rate', update='append', opts=options.lr)
- acc / loss
from tensorboard import SummaryWriter
writer = SummaryWriter()
for n_iter in range(100):
dummy_s1 = torch.rand(1)
writer.add_scalar('data/scalar1', dummy_s1[0], n_iter)
writer.close()
- img
from tensorboard import SummaryWriter
import torchvision.utils as vutils
writer = SummaryWriter()
if n_iter % 10 == 0:
x = vutils.make_grid(dummy_img, normalize=True, scale_each=True)
writer.add_image('Image', x, n_iter)
writer.close()
- 在一张图中加入两条曲线
for i in range(100):
writer.add_scalars('run_14h', {'xsinx':i*np.sin(i/r),
'xcosx':i*np.cos(i/r),
'tanx': np.tan(i/r)}, i)
7. Pytorch 加速
NVIDIA/DLAI: https://github.com/NVIDIA/DALI
Efficient-Pytorch: https://github.com/Lyken17/Efficient-PyTorch
NVIDIA/APEX: https://github.com/nvidia/apex
8. 性能分析工具
- nvidia-smi
- htop
- iotop
- nvtop
- py-spy
- strace
9. 深度学习绘图
10. 其他辅助工具
- byobu
- screen
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!