bioinf-jku/FCD

ValueError: Imaginary component

Closed this issue · 2 comments

Hello, I've got an issue for get_fcd function.

I reproduced this error in google colab

!pip install fcd
from fcd import get_fcd

smiles_list1 = ['COc1cccc(NC(=O)Cc2coc3ccc(OC)cc23)c1', 'Cc1noc(C)c1CN(C)C(=O)Nc1cc(F)cc(F)c1']
smiles_list2 = ['Oc1ccccc1-c1cccc2cnccc12', 'Cc1noc(C)c1CN(C)C(=O)Nc1cc(F)cc(F)c1']
get_fcd(smiles_list1, smiles_list2)

and I've got this result.


ValueError Traceback (most recent call last)
in <cell line: 3>()
1 smiles_list1 = ['COc1cccc(NC(=O)Cc2coc3ccc(OC)cc23)c1', 'Cc1noc(C)c1CN(C)C(=O)Nc1cc(F)cc(F)c1']
2 smiles_list2 = ['Oc1ccccc1-c1cccc2cnccc12', 'Cc1noc(C)c1CN(C)C(=O)Nc1cc(F)cc(F)c1']
----> 3 get_fcd(smiles_list1, smiles_list2)

1 frames
/usr/local/lib/python3.10/dist-packages/fcd/utils.py in calculate_frechet_distance(mu1, sigma1, mu2, sigma2, eps)
171 if not np.allclose(np.diagonal(covmean).imag, 0, atol=1e-3):
172 m = np.max(np.abs(covmean.imag))
--> 173 raise ValueError("Imaginary component {}".format(m))
174 covmean = covmean.real
175

ValueError: Imaginary component 1.90603044681631e+39

Do you have any idea to solve this?
I have to get fcd value for my project

hogru commented

Just browsing here for a different reason... just to make sure... does this also happen with more than 2 molecules? (since it calculates the variance...)

renzph commented

Hey @parkyjmit,
This never happened on the machines I used, but I could reproduce the error on Colab and on the machines used by GitHub actions.

It turned out to be a numerical issue. I fixed it in the new release and it should be working on colab now.