Skip to content

Commit

Permalink
fix histogram issue of default binning method
Browse files Browse the repository at this point in the history
  • Loading branch information
lanpa committed May 15, 2018
1 parent 4b8d642 commit 85a3c88
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
writer.add_text('Text', 'text logged at step:'+str(n_iter), n_iter)
writer.add_text('markdown Text', '''a|b\n-|-\nc|d''', n_iter)
for name, param in resnet18.named_parameters():
writer.add_histogram(name, param, n_iter)
if 'bn' not in name:
writer.add_histogram(name, param, n_iter)
writer.add_pr_curve('xoxo', np.random.randint(2, size=100), np.random.rand(100), n_iter) #needs tensorboard 0.4RC or later
writer.add_pr_curve_raw('prcurve with raw data', true_positive_counts,
false_positive_counts,
Expand Down
14 changes: 13 additions & 1 deletion tensorboardX/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,19 @@ def make_histogram(values, bins):
values = values.reshape(-1)
counts, limits = np.histogram(values, bins=bins)
limits = limits[1:]

# void Histogram::EncodeToProto in histogram.cc
for i, c in enumerate(counts):
if c > 0:
break
start = i - 1

for i, c in enumerate(reversed(counts)):
if c > 0:
break
end = -(i)

counts = counts[start:end]
limits = limits[start:end]
sum_sq = values.dot(values)
return HistogramProto(min=values.min(),
max=values.max(),
Expand Down

0 comments on commit 85a3c88

Please sign in to comment.