使用Tensorflow 2.1.0加载CuDNNLSTM时出错,>

问题描述 投票:0回答:1
我有:

from keras.layers import Input, LSTM, Dense, TimeDistributed, Activation, BatchNormalization, Dropout, Bidirectional from keras.models import Sequential from keras.utils import Sequence from tensorflow.compat.v1.keras.layers import CuDNNLSTM

self.model.add(CuDNNLSTM(lstm1_size, input_shape=( seq_length, feature_dim), return_sequences=True)) # self.model.add(BatchNormalization()) self.model.add(Dropout(0.2)) self.model.add(CuDNNLSTM(lstm2_size, return_sequences=True)) self.model.add(Dropout(0.2)) self.model.add(CuDNNLSTM(lstm3_size, return_sequences=True)) self.model.add(Dropout(0.2)) self.model.add(CuDNNLSTM(lstm4_size, return_sequences=True)) self.model.add(Dropout(0.2)) self.model.add(Dense(feature_dim, activation='linear'))

但是我得到的错误是:

TypeError: The added layer must be an instance of class Layer. Found: <tensorflow.python.keras.layers.cudnn_recurrent.CuDNNLSTM object at 0x140869be0>

我有:从keras.layers导入keras。从keras.layers导入Input,LSTM,Dense,TimeDistributed,Activation,BatchNormalization,Dropout,Bidirectional。 [

您正在kerastf.keras库之间混合导入,它们不是同一库,因此不支持这样做。

python tensorflow keras cudnn
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.