TensorFlow模型生成dump数据时,因tfdbg自身原因或运行环境原因,会出现tfdbg截断算子名,导致生成的npy文件名与预期不符,造成转换dump数据文件异常。
需要参考以下方法重新生成npy文件,使得npy文件名符合精度比对要求。
进入调试命令行交互模式后,输入run命令。
脚本内容如下:
#!/bin/bash timestamp=$[$(date +%s%N)/1000] index=1 while read -r line do tensor_index=`echo $line | awk '{print $4}'` echo "pt "$tensor_index" -n 0 -w "$((index++))"."$timestamp".npy" >> $2 done < $1
赋予pt_cmd.sh可执行权限并执行脚本。
bash pt_cmd.sh tensor_name tensor_name.txt
脚本内容如下:
#!/bin/bash timestamp=$[$(date +%s%N)/1000] while read -r line do tensor_index=`echo $line | awk '{print $2}'` real_file=`echo $line | awk '{print $6}'` changed1_tensor_index=${tensor_index//\//_} changed2_tensor_index=${changed1_tensor_index//:/.} echo $2/$real_file $2/$changed2_tensor_index"."$timestamp".npy" if [ -r $2/$real_file ] then mv $2/$real_file $2/$changed2_tensor_index"."$timestamp".npy" fi done < $1
赋予index_to_tensorname.sh可执行权限并执行脚本。
bash index_to_tensorname.sh tensor_name.txt npy_dir