Histogram showing incorrect data

Hello,

I am trying to plot my model’s errors using a histogram. The errors range between 0-8 and have been calculated for >2000 data points. I have tried several methods of logging this histogram on wandb, but each time it shows me this same plot (even for different runs of the model with different error counts):


As you can see from the table below, the counts are way off.

I have tried the following three methods:

errors = [[error] for error in torch.abs(predictions - test_targets).tolist()]
table = wandb.Table(data=errors, columns=["error"])
histogram = wandb.plot.histogram(
    table,
    "error",
    title="Error Histogram",
)

self.run.log({"Targets vs Errors_1": histogram})
self.run.log({"Targets vs Errors_2": wandb.Histogram(torch.abs(predictions - test_targets).tolist())})

error_counts = Counter(torch.abs(predictions - test_targets).tolist())
table = wandb.Table(
        data=[[k, v] for k, v in error_counts.items()], columns=["error", "count"]
    )
histogram = wandb.plot.histogram(
            table,
            "error",
            title="Error Histogram",
        )
self.run.log({"Targets vs Errors_3": histogram})

All of them show the same histogram as in the picture.

What am I doing wrong? How can I fix this?