在Keras通常会写:
model = Sequential() model.add(LSTM(n, input_shape=(ntimesteps, nfeatures), return_sequences=return_sequences, return_state=return_state))
如何在纯Tensorflow 2中模拟return_sequences和return_state特性?
return_sequences
return_state
6qftjkof1#
Keras是TensorFlow 2的高级API,因此您也可以这样做,唯一的区别是您不再导入Keras,而是
import tensorflow as tf print(tf.__version__) # 2.x model = tf.keras.Sequential() model.add(tf.keras.layers.LSTM(n, input_shape=(ntimesteps, nfeatures), return_sequences=return_sequences, return_state=return_state))
1条答案
按热度按时间6qftjkof1#
Keras是TensorFlow 2的高级API,因此您也可以这样做,唯一的区别是您不再导入Keras,而是