Skip to content

How to solve the RuntimeError: data set to a tensor that requires gradients must be floating point or complex dtype #334

@liaoyil

Description

@liaoyil

my test_A and test_B is png photo ,
when I use "python test.py --name arch2cons --netG local --ngf 32 --resize_or_crop none --label_nc 0 --dataroot "datasets/arch2cons" --input_nc 3 --no_instance ",
my terminal show me "
Pretrained network G has fewer layers; The following are not initialized:
['model', 'model1_1', 'model1_2', 'model2_1', 'model2_2', 'model3_1', 'model3_2']
Traceback (most recent call last):
File "D:\DC\Code\Code\pix2pixHD-master\test.py", line 33, in
model.type(torch.uint8)
File "D:\anaconda3\envs\pytorch\Lib\site-packages\torch\nn\modules\module.py", line 974, in type
return self._apply(lambda t: t.type(dst_type))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\anaconda3\envs\pytorch\Lib\site-packages\torch\nn\modules\module.py", line 802, in _apply
module._apply(fn)
File "D:\anaconda3\envs\pytorch\Lib\site-packages\torch\nn\modules\module.py", line 802, in _apply
module._apply(fn)
File "D:\anaconda3\envs\pytorch\Lib\site-packages\torch\nn\modules\module.py", line 802, in _apply
module._apply(fn)
File "D:\anaconda3\envs\pytorch\Lib\site-packages\torch\nn\modules\module.py", line 828, in _apply
param.data = param_applied
^^^^^^^^^^
RuntimeError: data set to a tensor that requires gradients must be floating point or complex dtype"
I'm just a sophomore with very little understanding about this , who can help me?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions