当前位置:网站首页>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 optional
dtypeor
outarguments is currently unsupported.
Basically becausedtype
perhapsout
The 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 supportfill_value
Optional... Is not setdtype
orout
In the case of parameter, provide Boolean or integer filling value . In fact, you need to set the parameter todtype=torch.long
anddtype=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/full
This order will do . - Finally, add this parameter directly
dtype=torch.long
That'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
边栏推荐
- : app: transformclasseswithrobustfordevrease meituan hot repair compilation error record
- Audio signal processing and coding - 2.5.3 the discrete cosine transform
- Tencent map and high logo removal method
- Yyds dry goods inventory stringprep --- Internet string preparation
- Oracle configuration st_ geometry
- Translation of audio signal processing and coding: Preface
- MySQL学习第五弹——事务及其操作特性详解
- One stop service platform for high-level talents and development of comprehensive service platform system for talents
- The flyer realizes page Jump through routing routes
- Introduction to micro build low code zero Foundation (lesson 3)
猜你喜欢
Introduction to micro build low code zero Foundation (lesson 3)
An idea of rendering pipeline based on FBO
C: generic reflection
c#:泛型反射
[记录]TypeError: this.getOptions is not a function
12个例子夯实promise基础
Client interns of a large factory share their experience face to face
Application of DCT transform
[报告] Microsoft :Application of deep learning methods in speech enhancement
2022.04.23 (lc_763_divided into letter interval)
随机推荐
2022.04.23(LC_763_划分字母区间)
MySQL Téléchargement et installation de la version Linux
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
SSDB Foundation
An algorithm problem was encountered during the interview_ Find the mirrored word pairs in the dictionary
I just want to leave a note for myself
Partage de la conception de l'alimentation électrique de commutation et illustration des compétences en conception de l'alimentation électrique
Use of fluent custom fonts and pictures
The difference between ordinary inner class and static inner class
SSDB foundation 3
为何PostgreSQL即将超越SQL Server?
mysql_linux版本的下载及安装详解
The platinum library cannot search the debug process records of some projection devices
Why is PostgreSQL about to surpass SQL Server?
Strange passion
binlog2sql 工具安装使用及问题汇总
Convert string to JSON
Redis optimization series (III) solve common problems after master-slave configuration
SQL server requires to query the information of all employees with surname 'Wang'
[record] typeerror: this getOptions is not a function