-
Notifications
You must be signed in to change notification settings - Fork 96
Open
Description
May I have a question about math operation on the sparse output of the descriptor, please?
I would like to do numpy operations on the sparse output. E.g., I want to do np.moveaxis, and einstein summation (attached code is creating derivatives of normalized soap).
As far as I know, this is not possible with the sparse output, and I would have to create dense array with .todense()? Or is there a way how to do a math operations?
At the end I am creating a neighbors list and want to do a matrix multiplication w.r.t. my pair list, so I would really like to keep a sparse representation until this moment, since my memory is exploding with a dense one.
Thank you for your answer
Best,
Martin
der, desc = soap.derivatives(molecule,attach=True)
norms = np.linalg.norm(desc,axis=-1)
norm_desc = desc/norms[:,None]
norms2 = norms**2
deriv_final = np.moveaxis(der,[0,1],[2,0])
# normal_soap_vector = np.array(normal_soap_vector)
hold = (np.einsum('ij,arkj->arik',desc,deriv_final,optimize="greedy"))
vd = np.einsum('akii->aki',hold,optimize="greedy")
r1 = np.einsum('akl,lj,l->aklj',vd,desc,1/norms,optimize="greedy")
f1 = np.einsum('aklj,l->aklj',deriv_final,norms,optimize="greedy")
normDer = np.einsum('aklj,l->aklj',f1-r1,1/norms2,optimize="greedy")Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels