Update show.

This commit is contained in:
Colin 2024-10-31 00:01:57 +08:00
parent 59449df047
commit 2ad977a072
1 changed files with 2 additions and 1 deletions

View File

@ -78,11 +78,12 @@ def DumpTensorToImage(tensor, name, forceSquare=False, scale=1.0, Contrast=None,
def DumpTensorToLog(tensor, name="log"): def DumpTensorToLog(tensor, name="log"):
shape = tensor.shape
tensor_mean = torch.mean(tensor).cpu().detach().numpy() tensor_mean = torch.mean(tensor).cpu().detach().numpy()
tensor_abs_mean = torch.mean(torch.abs(tensor)).cpu().detach().numpy()
tensor_range = (torch.max(tensor) - torch.min(tensor)).cpu().detach().numpy() tensor_range = (torch.max(tensor) - torch.min(tensor)).cpu().detach().numpy()
f = open(name, "w") f = open(name, "w")
f.writelines("tensor mean: %s" % tensor_mean + os.linesep) f.writelines("tensor mean: %s" % tensor_mean + os.linesep)
f.writelines("tensor abs mean: %s" % tensor_abs_mean + os.linesep)
f.writelines("tensor range: %s" % tensor_range + os.linesep) f.writelines("tensor range: %s" % tensor_range + os.linesep)
data = tensor.reshape([-1]).float().cpu().detach().numpy().tolist() data = tensor.reshape([-1]).float().cpu().detach().numpy().tolist()
for d in data: for d in data: