Skip to content

Commit

Permalink
Stats.dump, fix report if no data
Browse files Browse the repository at this point in the history
Fix #1458
  • Loading branch information
albertz committed Nov 8, 2023
1 parent dbef0ca commit 0b45494
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions returnn/util/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3868,11 +3868,15 @@ def dump(self, output_file_prefix=None, stream=None, stream_prefix=""):
)
else:
print(" %i seqs" % (self.num_seqs,), file=stream)
print(" Mean: %s" % (self.format_str(self.get_mean()),), file=stream)
print(" Std dev: %s" % (self.format_str(self.get_std_dev()),), file=stream)
print(" Min/max: %s / %s" % (self.format_str(self.min), self.format_str(self.max)), file=stream)
# print("Std dev (naive): %s" % numpy.sqrt(self.mean_sq - self.mean * self.mean), file=stream)
if self.num_seqs > 0:
print(" Mean: %s" % (self.format_str(self.get_mean()),), file=stream)
print(" Std dev: %s" % (self.format_str(self.get_std_dev()),), file=stream)
print(" Min/max: %s / %s" % (self.format_str(self.min), self.format_str(self.max)), file=stream)
# print("Std dev (naive): %s" % numpy.sqrt(self.mean_sq - self.mean * self.mean), file=stream)
else:
print(" (No data)", file=stream)
if output_file_prefix:
assert self.num_seqs > 0, "cannot dump stats without any data"
print(" Write mean/std-dev to %s.(mean|std_dev).txt." % (output_file_prefix,), file=stream)
numpy.savetxt("%s.mean.txt" % output_file_prefix, self.get_mean())
numpy.savetxt("%s.std_dev.txt" % output_file_prefix, self.get_std_dev())
Expand Down

0 comments on commit 0b45494

Please sign in to comment.