【发布时间】:2021-11-21 13:28:42
【问题描述】:
当我尝试使用 tf.keras.models.load_model() 加载模型时出现错误,并且出现以下错误
ValueError: The mask that was passed in was tf.RaggedTensor(values=Tensor("Placeholder_2:0", shape=(None,), dtype=bool),
row_splits=Tensor("Placeholder_3:0", shape=(None,), dtype=int64))
and cannot be applied to RaggedTensor inputs.
Please make sure that there is no mask passed in by upstream layers.
以下是我的模型架构
model = tf.keras.Sequential([
encoder,
tf.keras.layers.Embedding(input_dim=len(encoder.get_vocabulary()),output_dim=64,mask_zero=True),
tf.keras.layers.LSTM(64, return_sequences = True),
tf.keras.layers.GlobalMaxPool1D(),
tf.keras.layers.Dense(7)
])
编码层:
encoder = tf.keras.layers.experimental.preprocessing.TextVectorization(
max_tokens=VOCAB_SIZE)
模型保存为:model.save(PATH)
我正在从其他笔记本加载模型。我能得到一些帮助吗?
【问题讨论】:
标签: python keras lstm tensorflow2.0 tf.keras