Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: Found dtype Double but expected Float #23

Open
AnyAdapter opened this issue Dec 22, 2020 · 1 comment
Open

RuntimeError: Found dtype Double but expected Float #23

AnyAdapter opened this issue Dec 22, 2020 · 1 comment

Comments

@AnyAdapter
Copy link

--- load weight finish ---
Setting up a new session...
Max_iter = 120000, Batch_size = 20
Model will train on cuda:[0]
--- Focal_loss alpha = 0.25 ,将对背景类进行衰减,请在目标检测任务中使用 ---
--- Multiboxloss : α=0.25 γ=2 num_classes=21
Set optimizer : SGD (
Parameter Group 0
dampening: 0
initial_lr: 0.001
lr: 0.001
momentum: 0.9
nesterov: False
weight_decay: 0.0005
)
Set scheduler : <torch.optim.lr_scheduler.MultiStepLR object at 0x7f7d7f196e20>
Set lossfunc : multiboxloss(
(loc_loss_fn): SmoothL1Loss()
(cls_loss_fn): focal_loss()
)
Start Train......


/home/pdj/PycharmProjects/lyy/Retinanet-Pytorch/Data/Transfroms_utils.py:263: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
mode = random.choice(self.sample_options)
/home/pdj/PycharmProjects/lyy/Retinanet-Pytorch/Data/Transfroms_utils.py:263: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
mode = random.choice(self.sample_options)

Traceback (most recent call last):
File "/home/pdj/PycharmProjects/lyy/Retinanet-Pytorch/Demo_train.py", line 36, in
trainer(net, train_dataset)
File "/home/pdj/PycharmProjects/lyy/Retinanet-Pytorch/Model/trainer.py", line 122, in call
loss.backward()
File "/home/pdj/anaconda3/envs/lyy/lib/python3.8/site-packages/torch/tensor.py", line 221, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File "/home/pdj/anaconda3/envs/lyy/lib/python3.8/site-packages/torch/autograd/init.py", line 130, in backward
Variable._execution_engine.run_backward(
RuntimeError: Found dtype Double but expected Float

Process finished with exit code 1
请问个是为什么,我在Transforms.py中明明看到有ConvertFromInts()
并且在Transforms_utils.py中明明看到有return image.astype(np.float32), boxes, labels
为什么就报RuntimeError: Found dtype Double but expected Float这个错误了呢,
难道是 上面VisibleDeprecationWarning这个的问题。
库版本如下:
python 3.8.5 h7579374_1
pytorch 1.7.0 py3.8_cuda10.1.243_cudnn7.6.3_0 pytorch
torchvision 0.8.1 py38_cu101 pytorch
numpy 1.19.4 pypi_0 pypi
opencv-python 4.4.0.46 pypi_0 pypi
yacs 0.1.8 pypi_0 pypi
visdom 0.1.8.9 pypi_0 pypi
vizer 0.1.5 pypi_0 pypi

@lzb1
Copy link

lzb1 commented Aug 11, 2023

你好,我也有这个错误,请问你是如何解决的呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants