更新使用注释

This commit is contained in:
liuzx 2023-05-04 17:16:29 +08:00
parent 66d110fe7c
commit 4115f78ced
4 changed files with 25 additions and 13 deletions

View File

@ -4,7 +4,7 @@
使用注意事项
1本示例只支持单数据集训练如果是多数据集请参考多数据集训练示例train_for_multidataset.py
2本示例支持选择预训练模型单文件或多文件
3本示例需要用户定义的参数有--multi_data_url,--pretrain_url,--train_url,--device_target这4个参数在单数据集任务中必须定义
3本示例需要用户定义的参数有--multi_data_url,--pretrain_url,--train_url这3个参数在单数据集任务中必须定义
具体的含义如下
--multi_data_url是启智平台上选择的数据集的obs路径
--pretrain_url是启智平台上选择的预训练模型文件的obs路径
@ -78,10 +78,13 @@ if __name__ == "__main__":
PretrainToEnv(args.pretrain_url, pretrain_dir)
device_num = int(os.getenv('RANK_SIZE'))
#使用单卡时
if device_num == 1:
DatasetToEnv(args.multi_data_url,data_dir)
context.set_context(mode=context.GRAPH_MODE,device_target=args.device_target)
ds_train = create_dataset(os.path.join(data_dir, "train"), cfg.batch_size)
#使用数据集的方式
ds_train = create_dataset(os.path.join(data_dir + "/MNISTData", "train"), cfg.batch_size)
#使用多卡时
if device_num > 1:
# set device_id and init for multi-card training
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=int(os.getenv('ASCEND_DEVICE_ID')))
@ -96,7 +99,7 @@ if __name__ == "__main__":
#and Wait for 0th card to finish copying data
while not os.path.exists("/cache/download_input.txt"):
time.sleep(1)
ds_train = create_dataset_parallel(os.path.join(data_dir, "train"), cfg.batch_size)
ds_train = create_dataset_parallel(os.path.join(data_dir + "/MNISTData", "train"), cfg.batch_size)
network = LeNet5(cfg.num_classes)
net_loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True, reduction="mean")

View File

@ -1,13 +1,13 @@
"""
######################## Attention! ########################
使用注意事项
1本示例需要用户定义的参数有--multi_data_url,--pretrain_url,--train_url,--device_target这3个参数任务中必须定义
1本示例需要用户定义的参数有--multi_data_url,--pretrain_url,--train_url,这3个参数任务中必须定义
具体的含义如下
--multi_data_url是启智平台上选择的数据集的obs路径
--pretrain_url是启智平台上选择的预训练模型文件的obs路径
--train_url是训练结果回传到启智平台的obs路径
2用户需要调用OpenI.C2NETMultiDatasetToEnv等函数来实现数据集预训练模型文件的拷贝
3智算网络区别于启智的有
3智算网络区别于启智
(1)智算的数据集拷贝到训练镜像后需要解压请使用C2NETMultiDatasetToEnv函数
(2)智算任务结果不需要用户调用函数回传会在训练结束后自动回传结果
"""
@ -72,10 +72,13 @@ if __name__ == "__main__":
PretrainToEnv(args.pretrain_url, pretrain_dir)
device_num = int(os.getenv('RANK_SIZE'))
#使用单卡时
if device_num == 1:
DatasetToEnv(args.multi_data_url,data_dir)
context.set_context(mode=context.GRAPH_MODE,device_target=args.device_target)
ds_train = create_dataset(os.path.join(data_dir, "train"), cfg.batch_size)
#使用数据集的方式
ds_train = create_dataset(os.path.join(data_dir + "/MNISTData", "train"), cfg.batch_size)
#使用多卡时
if device_num > 1:
# set device_id and init for multi-card training
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=int(os.getenv('ASCEND_DEVICE_ID')))

View File

@ -64,10 +64,13 @@ if __name__ == "__main__":
DatasetToEnv(args.multi_data_url, data_dir)
device_num = int(os.getenv('RANK_SIZE'))
#使用单卡时
if device_num == 1:
DatasetToEnv(args.multi_data_url,data_dir)
context.set_context(mode=context.GRAPH_MODE,device_target=args.device_target)
ds_train = create_dataset(os.path.join(data_dir, "train"), cfg.batch_size)
#使用数据集的方式
ds_train = create_dataset(os.path.join(data_dir + "/MNISTData", "train"), cfg.batch_size)
#使用多卡时
if device_num > 1:
# set device_id and init for multi-card training
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=int(os.getenv('ASCEND_DEVICE_ID')))
@ -81,7 +84,7 @@ if __name__ == "__main__":
#If the cache file does not exist, it means that the copy data has not been completed,
#and Wait for 0th card to finish copying data
while not os.path.exists("/cache/download_input.txt"):
time.sleep(1)
time.sleep(1)
ds_train = create_dataset_parallel(os.path.join(data_dir + "/MNISTData", "train"), cfg.batch_size)
network = LeNet5(cfg.num_classes)

View File

@ -1,12 +1,12 @@
"""
######################## Attention! ########################
使用注意事项
1本示例需要用户定义的参数有--multi_data_url,--train_url,--device_target这3个参数任务中必须定义
1本示例需要用户定义的参数有--multi_data_url,--train_url,这2个参数任务中必须定义
具体的含义如下
--multi_data_url是启智平台上选择的数据集的obs路径
--train_url是训练结果回传到启智平台的obs路径
2用户需要调用OpenI.C2NETMultiDatasetToEnv等函数来实现数据集预训练模型文件的拷贝
3智算网络区别于启智的有
3智算网络区别于启智
(1)智算的数据集拷贝到训练镜像后需要解压请使用C2NETMultiDatasetToEnv函数
(2)智算任务结果不需要用户调用函数回传会在训练结束后自动回传
"""
@ -30,7 +30,7 @@ from OpenI import C2NETMultiDatasetToEnv as DatasetToEnv
parser = argparse.ArgumentParser(description='MindSpore Lenet Example')
parser.add_argument('--multi_data_url',
help='使用数据集训练时,需要定义的参数',
help='使用数据集,需要定义的参数',
default= '[{}]')
parser.add_argument('--train_url',
@ -61,10 +61,13 @@ if __name__ == "__main__":
###Initialize and copy data to training image
DatasetToEnv(args.multi_data_url, data_dir)
device_num = int(os.getenv('RANK_SIZE'))
#使用单卡时
if device_num == 1:
DatasetToEnv(args.multi_data_url,data_dir)
context.set_context(mode=context.GRAPH_MODE,device_target=args.device_target)
ds_train = create_dataset(os.path.join(data_dir, "train"), cfg.batch_size)
#使用数据集的方式
ds_train = create_dataset(os.path.join(data_dir + "/MNISTData", "train"), cfg.batch_size)
#使用多卡时
if device_num > 1:
# set device_id and init for multi-card training
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=int(os.getenv('ASCEND_DEVICE_ID')))
@ -78,7 +81,7 @@ if __name__ == "__main__":
#If the cache file does not exist, it means that the copy data has not been completed,
#and Wait for 0th card to finish copying data
while not os.path.exists("/cache/download_input.txt"):
time.sleep(1)
time.sleep(1)
ds_train = create_dataset_parallel(os.path.join(data_dir + "/MNISTData", "train"), cfg.batch_size)
network = LeNet5(cfg.num_classes)