LiangYu-Xidian / EPSOL

Sequence-based protein solubility prediction using multidimensional embedding
11 stars 2 forks source link

AttributeError: module 'keras.preprocessing.sequence' has no attribute 'pad_sequences' #2

Open abrozzi opened 2 years ago

abrozzi commented 2 years ago

Dear Liang Yu,

running the test example (new_test.fasta) I get this error

load data...
make data...
Traceback (most recent call last):
  File "EPSOL_main.py", line 140, in <module>
    main()
  File "EPSOL_main.py", line 102, in main
    x_train_seq, x_train_bi, x_train_tri, x_train_acc, x_train_acc20, x_train_ss, x_train_ss8, x_train_bio, y_train)
  File "EPSOL_main.py", line 56, in make_data
    x_seq = np.array(utils.pad_seq(seq, maxlen))
  File "/hpc/mydata/sna/ab552791/EPSOL/models/utils.py", line 7, in pad_seq
    return sequence.pad_sequences(sequence_list, maxlen)
AttributeError: module 'keras.preprocessing.sequence' has no attribute 'pad_sequences'

Thank you in advance

abrozzi commented 2 years ago

Dear Liang Yu,

I made the following changes:

In predict_new_seq.py I added:

from keras_preprocessing.sequence import pad_sequences

and changed:

    #x_seq = np.array(utils.pad_seq(seq, maxlen))
    #x_bi = np.array(utils.pad_seq(bi, maxlen))
    #x_tri = np.array(utils.pad_seq(tri, maxlen))

    #x_acc = np.array(utils.pad_seq(acc, maxlen))
    #x_acc20 = np.array(utils.pad_seq(acc20, maxlen))
    #x_ss = np.array(utils.pad_seq(ss, maxlen))
    #x_ss8 = np.array(utils.pad_seq(ss8, maxlen))

    x_seq = np.array(pad_sequences(seq, maxlen))
    x_bi = np.array(pad_sequences(bi, maxlen))
    x_tri = np.array(pad_sequences(tri, maxlen))

    x_acc = np.array(pad_sequences(acc, maxlen))
    x_acc20 = np.array(pad_sequences(acc20, maxlen))
    x_ss = np.array(pad_sequences(ss, maxlen))
    x_ss8 = np.array(pad_sequences(ss8, maxlen))

The output of

python3 predict_new_seq.py test/new_test.fasta test/new_test.ss test/new_test.ss8 test/new_test.acc test/new_test.acc20 test/new_test_src_bio new_test

is

load data...
make data...
-----------------------------------------------
x_seq shape: (2, 1200)
x_bi  shape: (2, 1200)
x_tri shape: (2, 1200)
x_acc shape: (2, 1200)
x_acc20 shape: (2, 1200)
x_ss shape: (2, 1200)
x_ss8 shape: (2, 1200)
x_bio shape: (2, 57)
2022-09-01 14:05:02.803012: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
1/1 [==============================] - 1s 968ms/step
-----------------------------------------------
EPSOL prediction finished!

and

cat new_test_prediction.txt 
Predicted_Class P0  P1
1   0.31234664  0.68765336
0   0.69362843  0.30637154

Liang Yu, is it the result correct?

HTH -A