Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

name 'Bidirectional' is not defined

Im following this tutorial and right when I want to initialize a sequential keras, like the code below:

model = keras.Sequential()
model.add(Bidirectional(
    CuDNNLSTM(Win_size, return_sequences=True),
    input_shape=(Win_size, X_train.shape[-1])))

I get an error saying :

NameError: name 'Bidirectional' is not defined

What is the problem ? it is the exact same code as in the tutorial.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You’re most likely missing the import statement from the tensorflow package.

It appears that’s there is a link to the source code in that article which shows the full import statement.

from tensorflow.keras.layers import Bidirectional

Keep in mind that the source code linked includes more imports but this would be directly related to the error you mentioned.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading