代码阅读笔记(1)

21年9月13日——代码阅读笔记

首先看模型部分:

root_dir_train = 'dataset\\train\\'
root_dir_test = 'dataset\\test\\'

训练集与测试集的根目录

def get_im_cv2(paths, img_rows, img_cols, color_type=3, normalize=True):
    '''
    参数:
        paths:要读取的图片路径列表
        img_rows:图片行
        img_cols:图片列
        color_type:图片颜色通道
    返回:
        imgs: 图片数组
    '''

返回的是图像的数组

def getimagedataandlabels(root_dir):
....
	X_data.append(imagepath)
	Y_data.append(current_image_class)
	
	return X_data, Y_data                

返回的是图像的路径,并且该路径下图像的标签(label)

np.random.seed(200)
np.random.shuffle(X_train)
np.random.seed(200)
np.random.shuffle(y_train)

设定随机数种子利用shuffle函数打乱数据集

def get_train_batch1(X_train, y_train, batch_size, img_w, img_h, color_type):
    """
    参数:
        X_train:所有图片路径列表
        y_train: 所有图片对应的标签列表
        batch_size:批次
        img_w:图片宽
        img_h:图片高
        color_type:图片类型
        is_argumentation:是否需要数据增强
    返回:
        一个generator,x: 获取的批次图片 y: 获取的图片对应的标签
    """
            yield ({
   'input_1': x
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值