我正在尝试访问一些存储在Tensorboard文件中的数据。我不希望在浏览器中使用Tensorboard GUI打开它,而是在python脚本中直接打开它,以便能够进行进一步的计算。
我现在的代码是:
file = # here, filename is provided
ea = event_accumulator.EventAccumulator(event_file[0])
ea.Reload()
print(ea.Tags())
现在,我的标签(ea.Tags())是某物。就像这样:
{'histograms': [], 'scalars': [], 'tensors': ['observable1', 'observable2' ], ...}
首先,有趣的是,我的观测数据不是保存在“标量”中,而是保存在“张量”中。我现在怎么能接触到这些可观测到的东西?我希望这两个可观察对象都会给出一个数组/一个值列表(这就是我感兴趣的),可能还有一些与张量相关的数据,比如形状、数据类型等等。
我已经尝试使用
x=ea.Tensors("observable1")
print(x[0])
或类似的,但我被困在那里,因为输出是某物。就像这样:
TensorEvent(wall_time=1234567890.987654, step=123, tensor_proto=dtype: DT_FLOAT
tensor_shape {
}
tensor_content: "\123Y\123@"
)
X的长度似乎固定在10,这对我来说是出乎意料的。有人有主意吗?我在网上找到的所有解释都是关于Tensorboard文件中的标量的。
发布于 2022-01-29 22:50:43
但前提是它以前写得很像
from torch.utils.tensorboard import SummaryWriter
tensorboard_writer=SummaryWriter(log_dir=logpath)
tensorboard_writer.add_scalar("loss_val", loss, parameter)
此示例将提取分数:
from tensorboard.backend.event_processing.event_accumulator import EventAccumulator
event_acc = EventAccumulator(logpath, size_guidance={"scalars": 0})
event_acc.Reload()
for scalar in event_acc.Tags()["scalars"]:
w_times, step_nums, vals = zip(*event_acc.Scalars(scalar))
也许写标量并不成功?
https://stackoverflow.com/questions/70897472
复制相似问题