当前位置:网站首页>RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
2022-04-23 19:15:00 【pflik-sj】
One 、 Problem description
Wrong presentation :
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out` arguments is currently unsupported. In PyTorch 1.7, when `dtype` and `out` are not set a bool fill value will return a tensor of torch.bool dtype, and an integral fill value will return a tensor of torch.long dtype.
Error full text prompt :
File "main.py", line 62, in <module>
run(train_dataset, val_dataset, test_dataset, args.save_dir, args.log_dir, model, args.epochs, args.batch_size, args.lr, args.lr_decay_factor, args.lr_decay_step_size, args.weight_decay, args.energy_and_force, args.p)
File "** Project path **/SphereNet_3D/spherenet_code/train.py", line 42, in run
train_loss = train(model, optimizer, train_loader, energy_and_force, p, loss_func, device)
File "** Project path **/SphereNet_3D/spherenet_code/train.py", line 75, in train
for step, batch_data in enumerate(tqdm(train_loader)):
File "** Virtual environment path **/miniconda3/envs/spherenet/lib/python3.7/site-packages/tqdm/std.py", line 1195, in __iter__
for obj in iterable:
File "** Virtual environment path **/miniconda3/envs/spherenet/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 363, in __next__
data = self._next_data()
File "** Virtual environment path **/miniconda3/envs/spherenet/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 403, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "** Virtual environment path **/miniconda3/envs/spherenet/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 47, in fetch
return self.collate_fn(data)
File "** Virtual environment path **/miniconda3/envs/spherenet/lib/python3.7/site-packages/torch_geometric/loader/dataloader.py", line 20, in __call__
self.exclude_keys)
File "** Virtual environment path **/miniconda3/envs/spherenet/lib/python3.7/site-packages/torch_geometric/data/batch.py", line 74, in from_data_list
exclude_keys=exclude_keys,
File "** Virtual environment path **/miniconda3/envs/spherenet/lib/python3.7/site-packages/torch_geometric/data/collate.py", line 109, in collate
out_store.batch = repeat_interleave(repeats, device=device)
File "** Virtual environment path **/miniconda3/envs/spherenet/lib/python3.7/site-packages/torch_geometric/data/collate.py", line 208, in repeat_interleave
outs = [torch.full((n, ), i, device=device) for i, n in enumerate(repeats)]
File "** Virtual environment path **/miniconda3/envs/spherenet/lib/python3.7/site-packages/torch_geometric/data/collate.py", line 208, in <listcomp>
outs = [torch.full((n, ), i, device=device) for i, n in enumerate(repeats)]
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out` arguments is currently unsupported. In PyTorch 1.7, when `dtype` and `out` are not set a bool fill value will return a tensor of torch.bool dtype, and an integral fill value will return a tensor of torch.long dtype.
Two 、 Situation analysis
-
The main reason for reporting errors is :
pytorch The version is a little low, There are some problems .
I usepytorch == 1.6.0, It is also within the scope of official tips . Generally, if there is a problem, go to the official website to have a look , Then check the details according to the error report . -
Error reporting this time ( It's usually the problem with the last line of code ):
outs = [torch.full((n, ), i, device=device) for i, n in enumerate(repeats)]
That is the :full()There's something wrong with this function .
And according to the prompt :RuntimeError: Providing a bool or integral fill value without setting the optionaldtypeoroutarguments is currently unsupported.
Basically becausedtypeperhapsoutThe problem with these two parameters . -
Let's see Official website ( According to their own version ):

Pay attention to the warning he said ! Currently does not support fill_valueOptional... Is not setdtypeoroutIn the case of parameter, provide Boolean or integer filling value . In fact, you need to set the parameter todtype=torch.longanddtype=torch.bool, You need to give a value to the parameter , Otherwise, there is no desired return value .
I tried it beforedtype=torch.float, But this doesn't solve the problem , And there are new problems . Refer to official documents , Personally, I feel this is wrong .
3、 ... and 、 resolvent
Method 1
- According to the last item of error report :
File "** Virtual environment path **/miniconda3/envs/spherenet/lib/python3.7/site-packages/torch_geometric/data/collate.py", line 208, in <listcomp>
outs = [torch.full((n, ), i, device=device) for i, n in enumerate(repeats)]
- Find the file according to the prompted path
collate.py, findtorch.full()function .
notes : stay linux Use directly in the environment/fullThis order will do . - Finally, add this parameter directly
dtype=torch.longThat's all right. .
The situation of my question is not in the original text , Not found in my codetorch.full(), So I modified the source code
Method 2
I must have checked a lot of methods before solving them , The more reliable one is the following .
Reference resources : Refer to the post
Just provide tensor Data type returned (dtype=torch.long) That's all right. , Instead of adding .torch.long() This way . The specific location of the addition is torch.full() In the parameter item of the function .
#self.register_buffer('words_to_words ', torch.full((len(vocab),),fill_value=unknown_idx) .long())
# But because it seems that there is a version problem, an error is reported , So it's changed to the following
self.register_buffer('words_to words ',torch.full(len(vocab),),fill_value=unknown_idx,dtype=torch.long))
版权声明
本文为[pflik-sj]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231913354198.html
边栏推荐
- An 8266 crash
- How to uninstall easyton
- 【历史上的今天】4 月 23 日:YouTube 上传第一个视频;网易云音乐正式上线;数字音频播放器的发明者出生
- Client interns of a large factory share their experience face to face
- 为何PostgreSQL即将超越SQL Server?
- Getting started with vcpkg
- 腾讯云GPU最佳实践-使用jupyter pycharm远程开发训练
- On the forced conversion of C language pointer
- Using 8266 as serial port debugging tool
- An idea of rendering pipeline based on FBO
猜你喜欢

Raspberry pie 18b20 temperature

12 examples to consolidate promise Foundation

浅谈c语言指针的强制转换

Using oes texture + glsurfaceview + JNI to realize player picture processing based on OpenGL es

Redis optimization series (III) solve common problems after master-slave configuration

SQL常用的命令

MySQL学习第五弹——事务及其操作特性详解

网络协议之:sctp流控制传输协议

Reflection on the performance of some OpenGL operations in the past

优先使用组合而不使用继承
随机推荐
The flyer realizes page Jump through routing routes
ArcMap publishing slicing service
[report] Microsoft: application of deep learning methods in speech enhancement
Sogou cell thesaurus analysis (only extract words and word frequency)
SSDB foundation 1
The platinum library cannot search the debug process records of some projection devices
Audio signal processing and coding - 2.5.3 the discrete cosine transform
On the forced conversion of C language pointer
The type initializer for ‘Gdip‘ threw an exception
Solve the problem of invalid listview Click
ArcMap连接 arcgis server
PostgreSQL
Strange passion
SSDB基础1
How about CICC wealth? Is it safe to open an account up there
该买什么设备,Keysight 给你挑好了
Network protocol: SCTP flow control transmission protocol
在渤海期货办理开户安全吗。
Class loading process of JVM
Xlslib use