coords[i]
is a list containing 3 elements x,y,z
and I want to get the derivative of G[i]
w.r.t. each of x,y,z
partially i.e. $\frac{\partial (G[i])}{\partial x_{i}}$, in some sort of a functional form like f(x)
so that I can pass a scalar x
to f()
.
This is one of the functions I am using as one of my inputs to a Neural Network and I want to find the partial derivative of my NN
w.r.t to x
. Hence, I am trying to find $ \frac{\partial (NN)}{\partial (G1[i])} . \frac{\partial (G1[i])}{\partial (x_{i})} $
import pytorch
def sym1(coords):
global avg
global eeta
global Rs
global e
R_avg=Rc
G1=[]
for i,m in enumerate(coords):
G1.append(0)
Ri=np.array(coords[i])
for j in range(i,len(coords)):
if(i!=j):
Rj=np.array(coords[j])
Rij=Ri-Rj
Rij_norm=np.linalg.norm(Rij)
sum1=e**(-eeta*((Rij_norm-Rs)**2))
sum2=cutoff(Rij_norm)
summation=sum1*sum2
G1[i]=G1[i]+summation
return G1