打印tensorboard记录的数据(解决tf2下的问题)
读取并导出Tensorboard中数据
读取tensorboard日志数据
代码
from tensorboard.backend.event_processing import event_accumulator
#加载日志数据
ea=event_accumulator.EventAccumulator(r'E:\Code\lastExp\output\logs\pm_last\events.out.tfevents.1535713476.DESKTOP-KMHR70T')
ea.Reload()
print(ea.scalars.Keys())
val_acc=ea.scalars.Items('val_acc')
print(len(val_acc))
print([(i.step,i.value) for i in val_acc])
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(6,4))
ax1=fig.add_subplot(111)
val_acc=ea.scalars.Items('val_acc')
ax1.plot([i.step for i in val_acc],[i.value for i in val_acc],label='val_acc')
ax1.set_xlim(0)
acc=ea.scalars.Items('acc')
ax1.plot([i.step for i in acc],[i.value for i in acc],label='acc')
ax1.set_xlabel("step")
ax1.set_ylabel("")
plt.legend(loc='lower right')
plt.show()
tf2报错
在使用tf2.x的时候,执行上述代码会报错,AttributeError: module 'tensorflow._api.v2.errors' has no attribute 'raise_exception_on_not_ok_status'
,解决办法是卸载tensorboard,按照 https://github.com/tensorflow/tensorboard/issues/2619 的说法,Please uninstall any copies of tensorboard
or tb-nightly
that you may have installed, and then run pip install tb-nightly
to grab the latest version. 进行适配,便可以直接使用了~
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器