当前位置:网站首页>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
边栏推荐
- [advanced level 11 of C language -- character and string functions and their simulation implementation (2)]
- Some records used by VS2010
- The flyer realizes page Jump through routing routes
- SSDB基础3
- openlayers 5.0 两种居中方式
- Parsing headless jsonarray arrays
- Wechat applet part of the mobile phone Preview PDF did not respond
- JS calculation time difference
- Openharmony open source developer growth plan, looking for new open source forces that change the world!
- 腾讯云GPU最佳实践-使用jupyter pycharm远程开发训练
猜你喜欢

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

Getting started with vcpkg

8266 obtain 18b20 temperature

The difference between ordinary inner class and static inner class

mysql_linux版本的下載及安裝詳解

ArcMap连接 arcgis server

Client interns of a large factory share their experience face to face

The platinum library cannot search the debug process records of some projection devices

2022.04.23(LC_714_买卖股票的最佳时机含手续费)

Installation, use and problem summary of binlog2sql tool
随机推荐
mysql通过binlog恢复或回滚数据
SSDB foundation 3
mysql_ Download and installation of Linux version
JS calculation time difference
Redis common interview questions
12 examples to consolidate promise Foundation
网络协议之:sctp流控制传输协议
[play with lighthouse] Tencent cloud lightweight server builds a full platform video analysis video download website
Oracle配置st_geometry
Tencent cloud GPU best practices - remote development training using jupyter pycharm
Common SQL commands
Coordinate conversion WGS-84 to gcj-02 and gcj-02 to WGS-84
The type initializer for ‘Gdip‘ threw an exception
SQL Server database in clause and exists clause conversion
Introduction to micro build low code zero Foundation (lesson 3)
SSDB基础1
Using 8266 as serial port debugging tool
2021-2022-2 ACM集训队每周程序设计竞赛(8)题解
SSDB foundation 2
An algorithm problem was encountered during the interview_ Find the mirrored word pairs in the dictionary