Question: Say I have a list of 50 random numbers. I want to group the numbers in a way that each subset has a min-max gap less than a cutoff 0.05. Below is my code.

```
import random

def cluster(data, cutoff):
    data.sort()
    res = []
    old_x = -10.
    for x in data:
        if abs(x - old_x) > cutoff:
            res.append([x])
        else:
            res[-1].append(x)
        old_x = x
    return res

cutoff = 0.05
data = [random.random() for _ in range(50)]
res = cluster(data, cutoff)

```

Check if all subsets have min-max gaps less than the cutoff:

```
print(all([(max(s) - min(s)) < cutoff for s in res]))

```

Output:

```
False

```

Obviously my code is not working. Any suggestions?

Answer: 
By default the parameters of the model are in FloatTensor datatype.

```
inputs = batch["image"].type(torch.cuda.FloatTensor).to(device)
labels = batch["label"].type(torch.cuda.FloatTensor).to(device)

```

should rectify this error or you can modify your dataloader class itself.
i wont recommend your first edit instead change the type of model to LongTensor using `model = model.type(torch.cuda.LongTensor)`