Skip to content

Commit 8ef8804

Browse files
authored
Merge pull request #1248 from MouseLand/bfloat16_train
check dtype in test data
2 parents 08f8dad + 7680eef commit 8ef8804

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

cellpose/train.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,11 @@ def train_seg(net, train_data=None, train_labels=None, train_files=None,
502502
xy=(bsize, bsize))[:2]
503503
X = torch.from_numpy(imgi).to(device)
504504
lbl = torch.from_numpy(lbl).to(device)
505+
506+
if X.dtype != net.dtype:
507+
X = X.to(net.dtype)
508+
lbl = lbl.to(net.dtype)
509+
505510
y = net(X)[0]
506511
loss = _loss_fn_seg(lbl, y, device)
507512
if y.shape[1] > 3:

0 commit comments

Comments
 (0)