我正在阅读以下代码段,此函数曾被调用为generator = image_gen.get_image_gen_rgb(nx, ny, cnt=20)
。我不清楚**kwargs
在get_image_gen_rgb
函数中的使用情况。 cnt=20
是否用于在n_image
create_batch
的参数
def get_image_gen_rgb(nx, ny, **kwargs):
def create_batch(n_image):
print("n_image: ",n_image)
X = np.zeros((n_image, nx, ny, 3))
Y = np.zeros((n_image, nx, ny,2))
for i in range(n_image):
x, Y[i,:,:,1] = create_image_and_label(nx,ny, **kwargs)
X[i] = to_rgb(x)
Y[i,:,:,0] = 1-Y[i,:,:,1]
return X, Y
create_batch.channels = 3
create_batch.n_class = 2
return create_batch
答案 0 :(得分:0)
cnt=20
用于通过x
推导Y
和create_image_and_label
的最后一个轴的第二个切片:
x, Y[i,:,:,1] = create_image_and_label(nx,ny, **kwargs) # kwargs = {'cnt': 20}