Im following this tutorial and right when I want to initialize a sequential keras, like the code below:
JavaScript
x
5
1
model = keras.Sequential()
2
model.add(Bidirectional(
3
CuDNNLSTM(Win_size, return_sequences=True),
4
input_shape=(Win_size, X_train.shape[-1])))
5
I get an error saying :
JavaScript
1
2
1
NameError: name 'Bidirectional' is not defined
2
What is the problem ? it is the exact same code as in the tutorial.
Advertisement
Answer
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.
JavaScript
1
2
1
from tensorflow.keras.layers import Bidirectional
2
Keep in mind that the source code linked includes more imports but this would be directly related to the error you mentioned.