sdtm_mapper icon indicating copy to clipboard operation
sdtm_mapper copied to clipboard

Compatibility issue

Open xiaolongluo1979 opened this issue 3 years ago • 1 comments
trafficstars

Hi, I was trying to use the package but ran into the following error. It may be version issue around Keras and Tensorflow. I tried importing packages differently but did not solve the problem. Any insight would be appreciated.

Thanks, Xiaolong


ImportError Traceback (most recent call last) in 6 7 # Here you import sdtm_mapper ----> 8 import sdtm_mapper.SDTMModels as sdtm 9 import sdtm_mapper.SDTMMapper as mapper 10 from sdtm_mapper import samples

~/anaconda3/lib/python3.8/site-packages/sdtm_mapper/SDTMModels.py in 17 from keras.callbacks import ModelCheckpoint 18 from keras.preprocessing.sequence import pad_sequences ---> 19 from keras.utils import to_categorical 20 from keras.engine import Layer 21 from sdtm_mapper import elmolayer as em

ImportError: cannot import name 'to_categorical' from 'keras.utils' (/home/xluo/anaconda3/lib/python3.8/site-packages/keras/utils/init.py)

xiaolongluo1979 avatar Jan 26 '22 21:01 xiaolongluo1979

Hi, I had the same issue. If you try from tensorflow.python.keras.utils.np_utils import to_categorical rather than keras.utils, it may not occur any error. However, I encountered the import error in the 20th line, and haven't found any solution yet.

I guess it's also a kind of Tensorflow version problem.


Additionally, for 20th line, How about using keras.engine.base_layer? I don't know actual meanings of all tf codes, so I just looked whether the code has a Layer class or method, and I found that the keras.engine.base_layer has the Layer class.

Pimool avatar Feb 22 '22 23:02 Pimool