maxhodak / keras-molecules

Autoencoder network for learning a continuous representation of molecular structures.
MIT License
519 stars 146 forks source link

preprocess.py reduce #69

Open charlestondance opened 7 years ago

charlestondance commented 7 years ago

Hi,

I am trying to run preprocess.py and there is an unresolved reference to reduce: charset = list(reduce(lambda x, y: set(y) | x, structures, set()))

however, if I:

from functools import reduce I then get the error.

Traceback (most recent call last): File "preprocess.py", line 88, in main() File "preprocess.py", line 60, in main h5f.create_dataset('charset', data = charset) File "C:\Users\dmcclymo\AppData\Local\Continuum\Anaconda3\lib\site-packages\h5py_hl\group.py", line 105, in crea taset dsid = dataset.make_new_dset(self, shape, dtype, data, **kwds) File "C:\Users\dmcclymo\AppData\Local\Continuum\Anaconda3\lib\site-packages\h5py_hl\dataset.py", line 93, in mak _dset tid = h5t.py_create(dtype, logical=1) File "h5py\h5t.pyx", line 1450, in h5py.h5t.py_create (C:\Minonda\conda-bld\h5py_1474482825505\work\h5py\h5t.c:16 File "h5py\h5t.pyx", line 1470, in h5py.h5t.py_create (C:\Minonda\conda-bld\h5py_1474482825505\work\h5py\h5t.c:15 File "h5py\h5t.pyx", line 1531, in h5py.h5t.py_create (C:\Minonda\conda-bld\h5py_1474482825505\work\h5py\h5t.c:15 TypeError: No conversion path for dtype: dtype('<U1')

charlestondance commented 7 years ago

ok i can turn it into a string this way

string_of_charset = "" for x, i in enumerate(charset): string_of_charset+=str(i[0])

But I get the error

Traceback (most recent call last): File "preprocess.py", line 93, in main() File "preprocess.py", line 80, in main apply_fn=lambda ch: np.array(map(one_hot_encoded_fn, File "preprocess.py", line 75, in create_chunk_dataset new_data[chunk_ixs, ...] = apply_fn(chunk) File "h5py_objects.pyx", line 54, in h5py._objects.with_phil.wrapper (C:\Minonda\conda-bld\h5py_1490028995708\work\h5 py_objects.c:2867) File "h5py_objects.pyx", line 55, in h5py._objects.with_phil.wrapper (C:\Minonda\conda-bld\h5py_1490028995708\work\h5 py_objects.c:2825) File "C:\Users\dmcclymo\AppData\Local\Continuum\Anaconda3\lib\site-packages\h5py_hl\dataset.py", line 629, in setit em for fspace in selection.broadcast(mshape): File "C:\Users\dmcclymo\AppData\Local\Continuum\Anaconda3\lib\site-packages\h5py_hl\selections.py", line 403, in broa dcast raise TypeError("Broadcasting is not supported for complex selections") TypeError: Broadcasting is not supported for complex selections

delton137 commented 7 years ago

I ran into the same problem. The problem went away when I went to Python2.7 by creating a Python 2.7 environment to run the code in. I did this using

conda create -n Python27 python=2.7

If you want to run in Python 3, this post might be helpful: one of the responders suggests using np.string_() instead of str.

dtchang commented 6 years ago

In Python 3.6 I tried: _charset = np.string__(charset)

It did away: TypeError: No conversion path for dtype: dtype('<U1')

However, it raised: TypeError: Broadcasting is not supported for complex selections

muu4649 commented 5 years ago

I have same error .... TypeError: Broadcasting is not supported for complex selections. Someone solved?