From 1f1d3cc1122ca2b32dcc90277324b4becf8fa9ef Mon Sep 17 00:00:00 2001 From: chunchun5958 Date: Fri, 25 Mar 2022 02:51:10 +0000 Subject: [PATCH 01/10] add --- .../cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py index 27acfe00c..f52c01695 100644 --- a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py +++ b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py @@ -148,7 +148,8 @@ def train(): batch_num = math.floor(input_img.shape[0]/args.batch_size) batch_id = 0 print(get_time(), npy, npy_path) - for step in range(1, int(batch_num)+5-int(batch_num)): #原来:int(batch_num)+1 + print("int(batch_num)-------------",int(batch_num)) + for step in range(1, int(batch_num)+1): #原来:int(batch_num)+1 print(get_time(), 'step', step) g_d_data, g_input_img, g_lr_img, g_hr_img, batch_id = data_train.get_next(batch_id, args.batch_size, d_data, input_img, lr_img, hr_img) feed_dict = {model.real_lr: g_d_data, model.input_data: g_input_img, model.lr_img: g_lr_img, model.hr_img:g_hr_img, model.training: True} @@ -158,7 +159,7 @@ def train(): _down, down_mse_loss = session.run([model.down_train_op, model.down_mse_loss], feed_dict) global_step += 1 - if global_step % args.print_interval == 1: + if global_step % args.print_interval == 1: #300 psnr = test(session, model, test_set) d_cost, g_cost, down_mse_loss, rs = session.run([ model.discrim_cost, model.generator_cost, model.down_mse_loss,merged], feed_dict) with open(os.path.join(args.ckpt_dir, 'log.txt'), 'a', encoding='utf-8') as f: -- Gitee From 518a766a1b8bdf4f27e105bef7b87ef39db35fb8 Mon Sep 17 00:00:00 2001 From: chunchun5958 Date: Fri, 25 Mar 2022 02:51:22 +0000 Subject: [PATCH 02/10] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/.keep diff --git a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/.keep b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/.keep new file mode 100644 index 000000000..e69de29bb -- Gitee From 50f9ac6e570723347089ebd10176c05b288e985e Mon Sep 17 00:00:00 2001 From: chunchun5958 Date: Fri, 25 Mar 2022 02:51:37 +0000 Subject: [PATCH 03/10] add TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh. --- .../GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh diff --git a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh new file mode 100644 index 000000000..e69de29bb -- Gitee From 0cbdd76b9ed6288f6de7bb307697d0dccf75dc07 Mon Sep 17 00:00:00 2001 From: chunchun5958 Date: Fri, 25 Mar 2022 02:54:24 +0000 Subject: [PATCH 04/10] add --- .../test/train_performance_1p.sh | 180 ++++++++++++++++++ 1 file changed, 180 insertions(+) diff --git a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh index e69de29bb..7933ab178 100644 --- a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh +++ b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh @@ -0,0 +1,180 @@ +#!/bin/bash + +#当前路径,不需要修改 +cur_path=`pwd`/../ + +#集合通信参数,不需要修改 + +export RANK_SIZE=1 +export JOB_ID=10087 +RANK_ID_START=0 + + +# 数据集路径,保持为空,不需要修改 +data_path='' +#预训练模型地址 +ckpt_path='' + +#设置默认日志级别,不需要改 +export ASCEND_GLOBAL_LOG_LEVEL=3 +#export ASCEND_DEVICE_ID=4 + +#基础参数,需要模型审视修改 +#网络名称,同目录名称 +Network="GFLmser_ID0206_for_TensorFlow" +#训练epoch +train_epochs= +#训练batch_size +batch_size=140 +#训练step +train_steps= +#学习率 +learning_rate=le-5 + +#TF2.X独有,需要模型审视修改 +export NPU_LOOP_SIZE=${train_steps} + +#维测参数,precision_mode需要模型审视修改 +precision_mode="allow_mix_precision" +#维持参数,以下不需要修改 +over_dump=False +data_dump_flag=False +data_dump_step="10" +profiling=False + +# 帮助信息,不需要修改 +if [[ $1 == --help || $1 == -h ]];then + echo"usage:./train_performance_1P.sh " + echo " " + echo "parameter explain: + --precision_mode precision mode(allow_fp32_to_fp16/force_fp16/must_keep_origin_dtype/allow_mix_precision) + --over_dump if or not over detection, default is False + --data_dump_flag data dump flag, default is False + --data_dump_step data dump step, default is 10 + --profiling if or not profiling for performance debug, default is False + --data_path source data of training + --ckpt_path model + -h/--help show help message + " + exit 1 +fi + +#参数校验,不需要修改 +for para in $* +do + if [[ $para == --precision_mode* ]];then + precision_mode=`echo ${para#*=}` + elif [[ $para == --over_dump* ]];then + over_dump=`echo ${para#*=}` + over_dump_path=${cur_path}/test/output/overflow_dump + mkdir -p ${over_dump_path} + elif [[ $para == --data_dump_flag* ]];then + data_dump_flag=`echo ${para#*=}` + data_dump_path=${cur_path}/test/output/data_dump + mkdir -p ${data_dump_path} + elif [[ $para == --data_dump_step* ]];then + data_dump_step=`echo ${para#*=}` + elif [[ $para == --profiling* ]];then + profiling=`echo ${para#*=}` + profiling_dump_path=${cur_path}/test/output/profiling + mkdir -p ${profiling_dump_path} + elif [[ $para == --data_path* ]];then + data_path=`echo ${para#*=}` + elif [[ $para == --ckpt_path* ]];then + ckpt_path=`echo ${para#*=}` + fi +done +# #校验是否传入data_path,不需要修改 +# if [[$data_path == ""]];then +# echo "[Error] para \"data_path\" must be confing" +# exit 1 +# fi + +#训练开始时间,不需要修改 +start_time=$(date +%s) + +#进入训练脚本目录,需要模型审视修改 +cd $cur_path/ +for((RANK_ID=$RANK_ID_START;RANK_ID<$((RANK_SIZE+RANK_ID_START));RANK_ID++)); +do + #设置环境变量,不需要修改 + echo "Device ID: $ASCEND_DEVICE_ID" + export RANK_ID=$RANK_ID + + + + #创建DeviceID输出目录,不需要修改 + if [ -d ${cur_path}/test/output/${ASCEND_DEVICE_ID} ];then + rm -rf ${cur_path}/test/output/${ASCEND_DEVICE_ID} + mkdir -p ${cur_path}/test/output/$ASCEND_DEVICE_ID/ckpt + else + mkdir -p ${cur_path}/test/output/$ASCEND_DEVICE_ID/ckpt + fi + # 绑核,不需要的绑核的模型删除,需要的模型审视修改 + let a=RANK_ID*12 + let b=RANK_ID+1 + let c=b*12-1 + #执行训练脚本,以下传参不需要修改,其他需要模型审视修改 + #--data_dir, --model_dir, --precision_mode, --over_dump, --over_dump_path,--data_dump_flag,--data_dump_step,--data_dump_path,--profiling,--profiling_dump_path + # sed -i "/_C.CACHE_DATA_FILENAMES_CACHE_PATH/s@"data/imagenet/"@"${data_path}/imagenet/"@g" config.py + # sed -i "/Squeezenet.save/s@"./ckpt/epoch_80.h5"@"${cur_path}/test/output/$ASCEND_DEVICE_ID/ckpt/epoch_80.h5"@g" train_npu.py + # sed -i "s@"./data/squeezenet_weights_tf_dim_ordering_tf_kernels.h5"@"${data_path}/squeezenet_weights_tf_dim_ordering_tf_kernels.h5"@g" models/squeezenet.py + # python3 train_npu.py > ${cur_path}/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 + # sed -i "s@"${data_path}/imagenet/"@"data/imagenet/"@g" config.py + # sed -i "s@"${cur_path}/test/output/$ASCEND_DEVICE_ID/ckpt/epoch_80.h5"@"./ckpt/epoch_80.h5"@g" train_npu.py + # sed -i "s@"${data_path}/squeezenet_weights_tf_dim_ordering_tf_kernels.h5"@"./data/squeezenet_weights_tf_dim_ordering_tf_kernels.h5"@g" models/squeezenet.py + python3 main_li.py \ + --data_dir=${data_path}/data \ + --ckpt_dir=$cur_path/new_ckpt \ + --epochs=1 \ + --print_interval=10 > ${cur_path}/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 +done +wait + +#训练结束时间,不需要修改 +end_time=$(date +%s) +e2e_time=$(( $end_time - $start_time )) + +#结果打印,不需要修改 +echo "------------------ Final result ------------------" +#输出性能FPS,需要模型审视修改 +TrainingTime=`grep 'ms' $cur_path/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log|awk 'END {print}'|awk -F ":" '{print $5}'|awk '{print$1}'` +FPS=`awk 'BEGIN{printf "%.2f\n",'${batch_size}'*1000/'${TrainingTime}'}'` +#打印,不需要修改 +echo "Final Performance TrainingTime : $TrainingTime" +echo "Final Performance images/sec : $FPS" + +#输出训练精度,需要模型审视修改 +#train_accuracy=`grep val_loss $cur_path/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log|grep step|grep -v ETA|awk 'END {print}'|awk '{print $11}'` + +#打印,不需要修改 +#echo "Final Train Accuracy : ${train_accuracy}" +echo "E2E Training Duration sec : $e2e_time" + +#性能看护结果汇总 +#训练用例信息,不需要修改 +BatchSize=${batch_size} +DeviceType=`uname -m` +CaseName=${Network}_bs${BatchSize}_${RANK_SIZE}'p'_'perf' + +##获取性能数据,不需要修改 +#吞吐量 +ActualFPS=${FPS} +#单迭代训练时长 + +#从train_$ASCEND_DEVICE_ID.log提取Loss到train_${CaseName}_loss.txt中,需要根据模型审视 +grep 'train_loss' $cur_path/test/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log|awk -F "=" '{print $2}' >> $cur_path/test/output/$ASCEND_DEVICE_ID/train_${CaseName}_loss.txt +#最后一个迭代loss值,不需要修改 +ActualLoss=`awk 'END {print}' $cur_path/test/output/$ASCEND_DEVICE_ID/train_${CaseName}_loss.txt` + +#关键信息打印到${CaseName}.log中,不需修改 +echo "Network = ${Network}" > $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "RankSize = ${RANK_SIZE}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "BatchSize = ${BatchSize}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "DeviceType = ${DeviceType}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "CaseName = ${CaseName}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "ActualFPS = ${ActualFPS}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log +#echo "TrainAccuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file -- Gitee From d4a52487d62f2b7d70a11b785da52ee90b0cfcde Mon Sep 17 00:00:00 2001 From: chunchun5958 Date: Fri, 25 Mar 2022 06:29:33 +0000 Subject: [PATCH 05/10] add --- .../GFLmser_ID0206_for_TensorFlow/main_li.py | 16 +++++++++++----- .../test/train_performance_1p.sh | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py index f52c01695..b5d94f600 100644 --- a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py +++ b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py @@ -23,6 +23,7 @@ import math import numpy as np import cv2 as cv #import moxing as mox +import time import GFLmser import data from npu_bridge.estimator import npu_ops @@ -53,6 +54,7 @@ tf.flags.DEFINE_float('beta', 0.05, '') tf.flags.DEFINE_integer('gpu', 1, '') tf.flags.DEFINE_integer('is_resume', 0, '') tf.flags.DEFINE_integer('epochs', 300, '') #add +tf.flags.DEFINE_integer('batch_num_less', 0, '') #add tf.flags.DEFINE_string('data_dir', './data', '')#add args = tf.flags.FLAGS @@ -142,19 +144,23 @@ def train(): for epo in range(start_epoch, args.epochs): train_npy_path = glob.glob(join(args.train_dir, 'G_*.npy')) - for npy, npy_path in enumerate(train_npy_path): + for npy, npy_path in enumerate(train_npy_path): #11 data_train = data.LmserData_train(npy_path, args.train_dir) d_data, input_img, lr_img, hr_img = data_train.get_data() #delete batch_num = math.floor(input_img.shape[0]/args.batch_size) batch_id = 0 print(get_time(), npy, npy_path) - print("int(batch_num)-------------",int(batch_num)) - for step in range(1, int(batch_num)+1): #原来:int(batch_num)+1 - print(get_time(), 'step', step) + print("int(batch_num)-------------",int(batch_num)) #142 + for step in range(1, int(batch_num)+1 - args.batch_num_less): #原来:142 + g_d_data, g_input_img, g_lr_img, g_hr_img, batch_id = data_train.get_next(batch_id, args.batch_size, d_data, input_img, lr_img, hr_img) feed_dict = {model.real_lr: g_d_data, model.input_data: g_input_img, model.lr_img: g_lr_img, model.hr_img:g_hr_img, model.training: True} + start = time.time() _up, up_mse_loss = session.run([model.up_train_op, model.up_mse_loss], feed_dict) _dis, d_cost = session.run([model.dis_train_op, model.discrim_cost], feed_dict) + perf = time.time - start + fps = args.batch_size / perf + print(get_time(), 'step', step, 'time' perf 'fps' fps) if step % 2 == 0: _down, down_mse_loss = session.run([model.down_train_op, model.down_mse_loss], feed_dict) global_step += 1 @@ -165,7 +171,7 @@ def train(): with open(os.path.join(args.ckpt_dir, 'log.txt'), 'a', encoding='utf-8') as f: s = str(get_time()) +" "+ "epo:{} npy:{} D_cost: {:.5f} G_cost:{:.5f} up_mse:{:.5f} down_mse:{:.5f} psnr:{}".format(epo, npy, d_cost, g_cost, up_mse_loss, down_mse_loss, psnr) f.write(s + '\n') - + writer.add_summary(rs, global_step) fake_lr_img, fake_hr_img, g_hr_img = session.run([model.fake_lr, model.train_out_hr, model.test_out_hr],feed_dict) diff --git a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh index 7933ab178..223e4ba72 100644 --- a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh +++ b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh @@ -127,6 +127,7 @@ do --data_dir=${data_path}/data \ --ckpt_dir=$cur_path/new_ckpt \ --epochs=1 \ + --batch_num_less=135 \ --print_interval=10 > ${cur_path}/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 done wait -- Gitee From 97bb86421783a838259da5bf4052f4a490faf690 Mon Sep 17 00:00:00 2001 From: chunchun5958 Date: Fri, 25 Mar 2022 07:10:16 +0000 Subject: [PATCH 06/10] add --- .../cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py index b5d94f600..d5dbdf611 100644 --- a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py +++ b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py @@ -152,7 +152,7 @@ def train(): print(get_time(), npy, npy_path) print("int(batch_num)-------------",int(batch_num)) #142 for step in range(1, int(batch_num)+1 - args.batch_num_less): #原来:142 - + print(get_time(), 'step', step) g_d_data, g_input_img, g_lr_img, g_hr_img, batch_id = data_train.get_next(batch_id, args.batch_size, d_data, input_img, lr_img, hr_img) feed_dict = {model.real_lr: g_d_data, model.input_data: g_input_img, model.lr_img: g_lr_img, model.hr_img:g_hr_img, model.training: True} start = time.time() @@ -160,7 +160,8 @@ def train(): _dis, d_cost = session.run([model.dis_train_op, model.discrim_cost], feed_dict) perf = time.time - start fps = args.batch_size / perf - print(get_time(), 'step', step, 'time' perf 'fps' fps) + print("time: {:.4f} fps: {:.4f}".format(perf,fps)) + if step % 2 == 0: _down, down_mse_loss = session.run([model.down_train_op, model.down_mse_loss], feed_dict) global_step += 1 -- Gitee From ca490c9bdc5b38a7024b3d0352a020054249cd26 Mon Sep 17 00:00:00 2001 From: chunchun5958 Date: Fri, 25 Mar 2022 07:15:13 +0000 Subject: [PATCH 07/10] ADD --- .../GFLmser_ID0206_for_TensorFlow/main_li.py | 2 +- .../test/train_performance_1p.sh | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py index d5dbdf611..c4e0f275a 100644 --- a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py +++ b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py @@ -170,7 +170,7 @@ def train(): psnr = test(session, model, test_set) d_cost, g_cost, down_mse_loss, rs = session.run([ model.discrim_cost, model.generator_cost, model.down_mse_loss,merged], feed_dict) with open(os.path.join(args.ckpt_dir, 'log.txt'), 'a', encoding='utf-8') as f: - s = str(get_time()) +" "+ "epo:{} npy:{} D_cost: {:.5f} G_cost:{:.5f} up_mse:{:.5f} down_mse:{:.5f} psnr:{}".format(epo, npy, d_cost, g_cost, up_mse_loss, down_mse_loss, psnr) + s = str(get_time()) +" "+ "epo:{} npy:{} D_cost: {:.5f} G_cost:{:.5f} up_mse:{:.5f} down_mse:{:.5f} psnr: {}".format(epo, npy, d_cost, g_cost, up_mse_loss, down_mse_loss, psnr) f.write(s + '\n') writer.add_summary(rs, global_step) diff --git a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh index 223e4ba72..640b0c0f1 100644 --- a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh +++ b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh @@ -128,7 +128,7 @@ do --ckpt_dir=$cur_path/new_ckpt \ --epochs=1 \ --batch_num_less=135 \ - --print_interval=10 > ${cur_path}/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 + --print_interval=10 >${cur_path}/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 done wait @@ -139,17 +139,18 @@ e2e_time=$(( $end_time - $start_time )) #结果打印,不需要修改 echo "------------------ Final result ------------------" #输出性能FPS,需要模型审视修改 -TrainingTime=`grep 'ms' $cur_path/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log|awk 'END {print}'|awk -F ":" '{print $5}'|awk '{print$1}'` -FPS=`awk 'BEGIN{printf "%.2f\n",'${batch_size}'*1000/'${TrainingTime}'}'` +TrainingTime=`grep 'time:' $cur_path/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log|awk 'END {print $2}'` +FPS=`grep 'time:' $cur_path/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log|awk 'END {print $4}'` +#`awk 'BEGIN{printf "%.2f\n",'${batch_size}'*1000/'${TrainingTime}'}'` #打印,不需要修改 echo "Final Performance TrainingTime : $TrainingTime" echo "Final Performance images/sec : $FPS" #输出训练精度,需要模型审视修改 -#train_accuracy=`grep val_loss $cur_path/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log|grep step|grep -v ETA|awk 'END {print}'|awk '{print $11}'` +train_accuracy=`grep psnr: $cur_path/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log|awk 'END {print $NF}'` #打印,不需要修改 -#echo "Final Train Accuracy : ${train_accuracy}" +echo "Final Train Accuracy : ${train_accuracy}" echo "E2E Training Duration sec : $e2e_time" #性能看护结果汇总 @@ -178,4 +179,4 @@ echo "ActualFPS = ${ActualFPS}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${Cas echo "TrainingTime = ${TrainingTime}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "E2ETrainingTime = ${e2e_time}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log -#echo "TrainAccuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file +echo "TrainAccuracy = ${train_accuracy}" >> $cur_path/test/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file -- Gitee From 0d6cbc090c4f9e5e3d4fef426580928321fc6b70 Mon Sep 17 00:00:00 2001 From: chunchun5958 Date: Fri, 25 Mar 2022 07:23:19 +0000 Subject: [PATCH 08/10] ADD --- .../contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py index c4e0f275a..a5b393cea 100644 --- a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py +++ b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py @@ -158,7 +158,7 @@ def train(): start = time.time() _up, up_mse_loss = session.run([model.up_train_op, model.up_mse_loss], feed_dict) _dis, d_cost = session.run([model.dis_train_op, model.discrim_cost], feed_dict) - perf = time.time - start + perf = time.time() - start fps = args.batch_size / perf print("time: {:.4f} fps: {:.4f}".format(perf,fps)) -- Gitee From 374c6ea29825e6352e34b885fc3e9029a7e6e828 Mon Sep 17 00:00:00 2001 From: chunchun5958 Date: Fri, 25 Mar 2022 08:12:56 +0000 Subject: [PATCH 09/10] add --- .../test/train_performance_1p.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh index 640b0c0f1..ee659a3e7 100644 --- a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh +++ b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh @@ -127,8 +127,8 @@ do --data_dir=${data_path}/data \ --ckpt_dir=$cur_path/new_ckpt \ --epochs=1 \ - --batch_num_less=135 \ - --print_interval=10 >${cur_path}/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 + --batch_num_less=135 \ + --print_interval=10 > ${cur_path}/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log 2>&1 done wait -- Gitee From 2b6470350005f424f479bb5d42bbf3f3fe2e1476 Mon Sep 17 00:00:00 2001 From: chunchun5958 Date: Fri, 25 Mar 2022 09:08:10 +0000 Subject: [PATCH 10/10] add --- .../cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py | 2 +- .../test/train_performance_1p.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py index a5b393cea..a4d62d7b0 100644 --- a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py +++ b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/main_li.py @@ -170,7 +170,7 @@ def train(): psnr = test(session, model, test_set) d_cost, g_cost, down_mse_loss, rs = session.run([ model.discrim_cost, model.generator_cost, model.down_mse_loss,merged], feed_dict) with open(os.path.join(args.ckpt_dir, 'log.txt'), 'a', encoding='utf-8') as f: - s = str(get_time()) +" "+ "epo:{} npy:{} D_cost: {:.5f} G_cost:{:.5f} up_mse:{:.5f} down_mse:{:.5f} psnr: {}".format(epo, npy, d_cost, g_cost, up_mse_loss, down_mse_loss, psnr) + s = str(get_time()) +" "+ "epo:{} npy:{} D_cost: {:.5f} G_cost:{:.5f} up_mse:{:.5f} down_mse:{:.5f} psnr: {}".format(epo, npy, d_cost, g_cost, up_mse_loss, down_mse_loss, psnr) f.write(s + '\n') writer.add_summary(rs, global_step) diff --git a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh index ee659a3e7..0bfe40830 100644 --- a/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh +++ b/TensorFlow/contrib/cv/gflmser/GFLmser_ID0206_for_TensorFlow/test/train_performance_1p.sh @@ -139,8 +139,8 @@ e2e_time=$(( $end_time - $start_time )) #结果打印,不需要修改 echo "------------------ Final result ------------------" #输出性能FPS,需要模型审视修改 -TrainingTime=`grep 'time:' $cur_path/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log|awk 'END {print $2}'` -FPS=`grep 'time:' $cur_path/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log|awk 'END {print $4}'` +TrainingTime=`grep 'fps:' $cur_path/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log|awk 'END {print $2}'` +FPS=`grep 'fps:' $cur_path/test/output/${ASCEND_DEVICE_ID}/train_${ASCEND_DEVICE_ID}.log|awk 'END {print $4}'` #`awk 'BEGIN{printf "%.2f\n",'${batch_size}'*1000/'${TrainingTime}'}'` #打印,不需要修改 echo "Final Performance TrainingTime : $TrainingTime" -- Gitee