当前位置:网站首页>RuntimeError: set_ sizes_ contiguous is not allowed on a Tensor created from .data or .detach().
RuntimeError: set_ sizes_ contiguous is not allowed on a Tensor created from .data or .detach().
2022-07-28 22:52:00 【Meteor shower ADI】
The error information is as follows :
RuntimeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_19156/279535578.py in <module>
59
60 #2、 Generate a fake picture with noise
---> 61 noise.data.resize_(data.size()[0], input_dim, 1, 1).normal_(0, 1) # Noise is a input_dim The vector of the dimension
62 # Feed the generator to generate images
63 fake_pic=netG(noise).detach() # there detach It is to make the generator not participate in gradient update
RuntimeError: set_sizes_contiguous is not allowed on a Tensor created from .data or .detach().
If your intent is to change the metadata of a Tensor (such as sizes / strides / storage / storage_offset)
without autograd tracking the change, remove the .data / .detach() call and wrap the change in a `with torch.no_grad():` block.
For example, change:
x.data.set_(y)
to:
with torch.no_grad():
x.set_(y)
According to the error prompt, change and remove .data After that, the operation still reports an error , The error information is as follows :
RuntimeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_19156/1757806420.py in <module>
59
60 #2、 Generate a fake picture with noise
---> 61 noise.resize_(data.size()[0], input_dim, 1, 1).normal_(0, 1) # Noise is a input_dim The vector of the dimension
62 # Feed the generator to generate images
63 fake_pic=netG(noise).detach() # there detach It is to make the generator not participate in gradient update
RuntimeError: cannot resize variables that require grad
Then I checked a lot of information on the Internet and failed to solve the problem , Finally, by removing the front noise Parameters of require_grad Option or make it false
# Input and output of the model
# Generate a random noise input to the generator
noise=torch.tensor((batch_size, input_dim, 1, 1), dtype = torch.float, requires_grad = True)Modify it as follows :
# Input and output of the model
# Generate a random noise input to the generator
noise=torch.tensor((batch_size, input_dim, 1, 1), dtype = torch.float)
# Fixed noise is used to evaluate the results of the generator , It remains the same throughout the training process
fixed_noise=torch.FloatTensor(batch_size, input_dim, 1, 1).normal_(0,1).requires_grad_(True)Problem solvable .
边栏推荐
- Differernet [anomaly detection: normalizing flow]
- Target segmentation learning
- Using PCL to batch display PCD point cloud data flow
- C language to realize string reverse order arrangement
- DIP-VBTV: Color Image Restoration Model Combining Deep Image Prior and Vector Bundle Total Variation
- STM32_ Hal library driven framework
- Summary of the problem that MathType formula does not correspond in word
- Stm32subeide (10) -- ADC scans multiple channels in DMA mode
- fatal error: io. h: No such file or directory
- Reading of "robust and communication efficient federated learning from non-i.i.d. data"
猜你喜欢

无代码开发平台通讯录导出入门教程

Es personal arrangement of relevant interview questions

NPM run dev, automatically open the browser after running the project

Summary of common formula notes for solving problems in Higher Mathematics

STM32 - Basic timer (tim6, tim7) working process, interpretation function block diagram, timing analysis, cycle calculation

Multi activity disaster recovery construction after 713 failure of station B | takintalks share
![Ocr-gan [anomaly detection: Reconstruction Based]](/img/16/62d962288c192b3df2fdb518d7127e.gif)
Ocr-gan [anomaly detection: Reconstruction Based]
![Memseg [anomaly detection: embedded based]](/img/10/aea2b6ecf55e04fe24f78e5fb897be.png)
Memseg [anomaly detection: embedded based]

Vscode ROS configuration GDB debugging error record

Stm32+ four pin OLED screen + Chinese character mold taking
随机推荐
fatal error: io. h: No such file or directory
Wheel 6: qserialport serial port data transceiver
1e3是浮点数?
Improvement 17 of yolov5: cnn+transformer -- integrating bottleneck transformers
Binary source code, inverse code, complement code
轮子六:QSerialPort 串口数据 收发
Qt+ffmpeg environment construction
Padim [anomaly detection: embedded based]
Summary of C language learning content
弹框遮罩层「建议收藏」
Redis related
CS flow [abnormal detection: normalizing flow]
console.log()控制台显示...解决办法
STM32 - Basic timer (tim6, tim7) working process, interpretation function block diagram, timing analysis, cycle calculation
How to install and use PHP library neo4j
Paper reading vision gnn: an image is worth graph of nodes
OSV-q The size of tensor a (3) must match the size of tensor b (320) at non-singleton dimension 3
Leetcode exercise 3 - palindromes
[connect your mobile phone wirelessly] - debug your mobile device wirelessly via LAN
shell脚本基础——Shell运行原理+变量、数组定义