title: How to assign a new value to a pytorch Variable without breaking backpropagation?
body: <p>I have a pytorch variable that is used as a trainable input for a model. At some point I need to manually reassign all values in this variable.</p>
  <p>How can I do that without breaking the connections with the loss function?</p>
  <p>Suppose the current values are <code>[1.2, 3.2, 43.2]</code> and I simply want them to become <code>[1,2,3]</code>.</p>
  <hr />
  <h3>Edit</h3>
  <p>At the time I asked this question, I hadn't realized that PyTorch doesn't have a static graph as Tensorflow or Keras do.</p>
  <p>In PyTorch, the training loop is made manually and you need to call everything in each training step. (There isn't the notion of placeholder + static graph for later feeding data).</p>
  <p>Consequently, we can't &quot;break the graph&quot;, since we will use the new variable to perform all the further computations again. I was worried about a problem that happens in Keras, not in PyTorch.</p>