1.sys.stdout,sys.stderr,print
1.1print与sys.stdout
print语句就是调用sys.stdout.write()这个方法。下面这篇博文讲得不错
参考这篇博文
python的print与sys.stdout
1.2 sys.stdout与sys.stderr
stderr与stdout一样,用于重定向错误信息至某个文件
>>> import sys
>>> sys.stderr = open('errlog.txt','a')
>>> a /5
这个时候没有输出,同个目录下多了errlog.txt文件,打开文件,显示如下。上面的错误信息保存到errlog.txt文件了
2.logging
3.imgaug
用于做图片增强处理,感觉还是蛮不错的
from imgaug import augmenters as iaa
# 每次使用0~2个Augmenter来处理图片,每个batch中的Augmenters顺序一样。
# Fliplr 0.5 is the probability, horizontally flip 50% of the images
augmentation = iaa.SomeOf((0, 2), [
iaa.Fliplr(0.5),
iaa.Flipud(0.5),
iaa.OneOf([iaa.Affine(rotate=90),
iaa.Affine(rotate=180),
iaa.Affine(rotate=270)]),
iaa.Multiply((0.8, 1.5)),
iaa.GaussianBlur(sigma=(0.0, 5.0))])
4.torch.device
torch.device 有cpu,或者cuda
torch.cuda.device_count()可以看用了多少GPU
>>> torch.device('cpu')
device(type='cpu')
>>> torch.device('cuda')
device(type='cuda')
torch.cuda.device_count()