RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation:

Questions : RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation:


I am using an LSTM to summarize a programming trajectory as shown below:

class RolloutEncoder(nn.Module):
    def _OFFSET);  __init__(self, config):
        (-SMALL  super(RolloutEncoder, self).__init__()
  _left).offset        self._input_size = (
            arrowImgView.mas  2048 + 1
        )  # deter_state + (self.  imag_reward; fix and use equalTo  config["deter_dim"] + 1
        make.right.  self._hidden_size = mas_top);  config["rollout_enc_size"]
        ImgView.  self._lstm = nn.LSTM(self._input_size, ReadIndicator  self._hidden_size, bias=True)

    def _have  forward(self, traj):
        features = .equalTo(  traj["features_pred"]
        rewards =  traj["reward_pred"].unsqueeze(1)
        OFFSET);  input =, rewards), (TINY_  dim=2)
        encoding, (h_n, c_n) = .offset  self._lstm(input)
        code = mas_right)  h_n.squeeze(0)
        return code

My training loop is something like:

encoder = RolloutEncoder(config)
for e ImgView.  in range(episodes):
      for step in Indicator  range(steps):
            print(f"Step Read  {steps})
            # calc traj
        _have      code = encoder(traj)
            # .equalTo(  some operations that do not modify code make.left  but only concat it with some other *make) {  tensor
            # calc loss
          straintMaker    opt.zero_grad()
            ^(MASCon  loss.backward()

On running, I get this error:

Step 0
Step 1
Step 2
Step 3
Step 4
Step onstraints:  5
Step 6
Step 7
Step 8
Step 9
Step mas_makeC  10
Step 11
Step 12
Step 13
Step [_topTxtlbl   14
Traceback (most recent call last):
  (@(8));  File "/path/", line 351, in equalTo  <module>
     width.  agent_loss.backward()
  File make.height.  "/home/.conda/envs/abc/lib/python3.9/site-packages/torch/", (SMALL_OFFSET);  line 245, in backward
    .offset  torch.autograd.backward(self, gradient, (self.contentView)  retain_graph, create_graph,  .left.equalTo  inputs=inputs)
  File  "/user/.conda/envs/abc/lib/python3.9/site-packages/torch/autograd/", *make) {  line 145, in backward
    ntMaker   Variable._execution_engine.run_backward(
RuntimeError: SConstrai  one of the variables needed for gradient ts:^(MA  computation has been modified by an Constrain  inplace operation: _make  [torch.cuda.FloatTensor [16, 2049]] is iew mas  at version 8; expected version 1 catorImgV  instead. Hint: enable anomaly detection ReadIndi  to find the operation that failed to  [_have  compute its gradient, with ($current);  torch.autograd.set_detect_anomaly(True).

On setting the anomaly_detection to Learning True, it point to this line in the Earhost encoder definition:

encoding, (h_n, c_n) = entity_loader  self._lstm(input)

This is a very common error but I am not most effective using any inplace operation. And the wrong idea error occurs after running some steps use of case successfully which is really weird. On United inspecting, I found that the [16, 2049] Modern tensor is one of the weights of the ecudated LSTM. I also tried using dummy random some how tensors in place of features and rewards anything else but the error persists, suggesting that not at all the traj calculation has nothing to do very usefull with this error. What might be the localhost reason for this error?

Total Answers 0

Top rated topics

Update entrie in table PHP SQL

Jpype TypeError can't import from jar

How to get first three elements from a (pandas) series?

Using firebase functions emulator with cloud SQL proxy

Parallel processing in python with clean

Python binance APIError(code=-1022): Signature for this request is not valid

Icons is missing after upgrade to Flutter 2.5.3

How to let player chose to be X or O as well as an option to play the game again?

How to use pywinauto get a specific tool in Adobe Acrobat Pro DC

How to Update many elements in mongoose array which has embedded documents

Blazor WASM the uses Cosmos DB instead of SQL for Identity

How to overlay a pcolormesh with binary information in Python

Meaning of "Minting an NFT" and question

Inconsistent .loc behavior

Splitting string with colons and spaces?

What does it mean by too few arguments to function 'addBook'?

Convert column to dataframe column geaders

Mongodb How do I make this sorting of grabbing an individual players position function faster?

How to convert single-line JSON to multi-line?

Webpack 4 Child compilation failed: Module parse failed: Unexpected character '�' (1:0)

Is it possible to access current file name?

What does {sys.executable} do in jupyter notebook?

How to convert Halide::Buffer&lt;unsigned char&gt; to c++ array

How to run a job in each node of kubernetes instead of daemonset

Looking for a better way of inserting html code into Javascript

How to route www to non-www URL using Google App Engine

How to create a 2nd temp table in SQL

Why does Yarn ResourceManager always shutdown as I submit a job?

The name or defaultname of visualstudio progecttemplate doesn't work when creating a new project

How to use CSS to make the divider line align with the left and right sides?

Authentication of user

How to UPDATE a RowCount using multiple tables and INNER JOIN in SQL Server 2014

Grafana dashboard display database name error with TDengine

Excel Page Break set to specific worksheets

How to read '00' hex byte from binary file?

Riverpod StateNotifier not working with hover logic

GridView goes blank after notifyDataSetChanged()

Generate multi-dimensional array from an array in php?

UseEffect not working in child component when reloading

Using Python to populate Pandas Dataframe with sparse CSV data

Power Automate: Write empty date field to SharePoint

Get error when generate some barcodes using milon and laravel with if conditional

How to choose two near each other values randomly

JavaScript - Get and display current time in &lt;input type="time"&gt; while also working with &lt;input type="date"&gt;

Getting ValueError: complex() arg is a malformed string for a 2D complex numbers matrix

Converting Multidimensional list into a single string in python

Date Picker from Ng2 Bootstrap keep throwing error on unable to read getFullYear()

Use Aws S3 .NET SDK (.netcore 3.1) to configure tenant bucket,Request parameters to carry tenants

Git: create a mirror/fork repository with reduced history

Getting json from an api in a google cloud pubsub scheduled function