Python 自动增强函数的返回
我正在研究RandAugment,有一个python函数,我不理解它的返回。这是:Python 自动增强函数的返回,python,function,deep-learning,Python,Function,Deep Learning,我正在研究RandAugment,有一个python函数,我不理解它的返回。这是: transforms = ['Identity', 'AutoContrast','Equalize', 'Rotate','Solarize','Color','Posterize', 'Contrast','Brightness','Sharpness','ShearX', 'ShearY','TranslateX','TranslateY'] def randAugment(N,M): # génèr
transforms = ['Identity', 'AutoContrast','Equalize',
'Rotate','Solarize','Color','Posterize',
'Contrast','Brightness','Sharpness','ShearX',
'ShearY','TranslateX','TranslateY']
def randAugment(N,M):
# génère un ensemble de distorsion d'images
# Arguments :
# N : nombre de transformations
# M : degré pour toutes les transformations
sampled_ops = np.random.choice(transforms,N)
return[(op,M) for op in sampled_ops]
我不明白为什么要使用一种循环,因为sampled_ops不是一个列表,所以其中只有一个值。如果有人能给我解释一下,我将不胜感激!提前感谢。实际上,将返回大小为N的1D数组,而不是单个值。具体来说,它将从transforms
列表中随机选择N个变换,然后选择循环:
[(op,M) for op in sampled_ops]
将创建一个列表,其中包含samples\u ops
和M
值中转换之间的所有对