Hi, everybody. Is there any method to compute partial derivatives? For example, y = x and z = x + y. I want dz/dx = 1, but autograd gives me 2. In tensorflow, there is a stop_gradients in tf.gradients. But in pytorch I couldn’t find this kind of thing.

`z = x + y.detach()`

.

By the way, partial derivative has nothing to do with the quantity you want to get.

Thanks. It works for this case, but it causes other problems. If later I still want to compute dz/dy (=1) and dy/dx (=1), I have to re-define the functions.

The thing is dz/dx isn’t 1. It is 2. So unless you do something special, it can never achieve both dz/dz=1 and dy/dx=1.