Why does the following work

```
x = torch.tensor([True, False, True])
x.sum().div(len(x))
```

and this one not ?

```
x = torch.tensor([True, False, True])
x.mean()
```

numpy.mean also works on boolean arrays.

Why does the following work

```
x = torch.tensor([True, False, True])
x.sum().div(len(x))
```

and this one not ?

```
x = torch.tensor([True, False, True])
x.mean()
```

numpy.mean also works on boolean arrays.

It seems that `numpy`

doesnâ€™t work in the first code snippet:

```
x = torch.tensor([True, False, True])
x.numpy().sum().div(len(x))
> AttributeError: 'numpy.int64' object has no attribute 'div'
```

so the support seems to be swapped.

Feel free to create a feature request to support `mean`

on `BoolTensor`

s and to discuss it with the code owners.

thatâ€™s bananas, didnâ€™t expect that at all.

Who would have thought of this divergence .

Cheers!

1 Like