IntuitionEngineeringTeam / chars2vec

Character-based word embeddings model based on RNN for handling real world texts
Apache License 2.0
171 stars 37 forks source link

Using vectorize_words leads to AttributeError #12

Open gabecano4308 opened 2 years ago

gabecano4308 commented 2 years ago

Hello,

I am using keras ==2.9.0 and tensorflow ==2.9.1. I'm using pretrained eng_50 model like so --

c2v_model = chars2vec.load_model('eng_50')

However, when I use the vectorize_words method on my list of strings, I get the following AttributeError:

c2v_model.vectorize_words(std_job_list)


AttributeError Traceback (most recent call last)

in ----> 1 c2v_model.vectorize_words(std_job_list) ~/anaconda3/envs/JupyterSystemEnv/lib/python3.7/site-packages/chars2vec/model.py in vectorize_words(self, words, maxlen_padseq) 150 list_of_embeddings.append(np.array(current_embedding)) 151 --> 152 embeddings_pad_seq = keras.preprocessing.sequence.pad_sequences(list_of_embeddings, maxlen=maxlen_padseq) 153 new_words_vectors = self.embedding_model.predict([embeddings_pad_seq]) 154 AttributeError: module 'keras.preprocessing.sequence' has no attribute 'pad_sequences' ----------------------------------------------------------------------------------------- I'm not sure if there's a specific version I need to be using for keras/tensorflow. or if I'm missing something separate Any advice on this would be appreciated! Thanks
theloni-monk commented 1 year ago

I am in the same situation and have the Attribute Error: module 'keras' has no attribute 'preprocessing'

Is it perhaps a versioning issue? What version of Keras was used in this project?

helenkimber commented 1 year ago

I got it to work with tensorflow==2.8.4, keras==2.8.0

theloni-monk commented 1 year ago

I fixed it by replacing Keras with tf.compat.v1.keras in all instances