训练卷积神经网络来识别简单的加噪四位字母数字验证码 # 生成一个训练batch
# 生成一个训练batch
def get_next_batch(batch_size=64):
    batch_x = np.zeros([batch_size, IMAGE_HEIGHT * IMAGE_WIDTH])
    batch_y = np.zeros([batch_size, MAX_CAPTCHA * CHAR_SET_LEN])
    def wrap_gen_captcha_text_and_image(i):
        while True:
            text, image = gen_captcha_text_and_image(i)
            if image.shape == (60, 160, 3):
                return text, image
    for i in range(batch_size):
        text, image = wrap_gen_captcha_text_and_image(i)
        image = convert2gray(image)
        batch_x[i, :] = image.flatten() / 255
        batch_y[i, :] = text2vec(text)
return batch_x, batch_y

 
  
					
				
评论