[英]why may code generates the error while i fit the model" ValueError: Layer "sequential_3" expects 1 input(s), but it received 2 input tensors
while I am trying to fit the model on Quora dataset this error generated.当我试图在 Quora 数据集上安装 model 时,会产生此错误。 please help me.
请帮我。 i am a very beginner in this field
我是这个领域的初学者
from tensorflow.keras.layers import *
#create the embedding layer
#len(embeddings) = 85790, embeddingDim = 300
e = Embedding(len(embeddings), embeddingDim, weights=
[embeddings],input_length=maxSeqLength,trainable=False)
#embedding_layer = Embedding(total_words, embedding_dim, weights=[embedding_matrix],
input_length=max_length, trainable=False)
from tensorflow.keras.models import *
from tensorflow.keras.layers import *
# define model
model = Sequential()
model.add(e)
model.add(SimpleRNN(128,activation='relu',return_sequences= True))
model.add(SimpleRNN(256,activation='relu'))
model.add(Dense(1, activation='sigmoid'))
print(model.summary())
model.fit([X_train['left'], X_train['right']], Y_train,epochs=5,validation_data=
([X_validation['left'], X_validation['right']], Y_validation))
validation_data
needs to be a tuple, as stated in the Keras API reference ( link ): validation_data
需要是一个元组,如 Keras API 参考( 链接)中所述:
validation_data : ... validation_data could be: -
tuple
(x_val, y_val) of Numpy arrays or tensors -tuple
(x_val, y_val, val_sample_weights) of Numpy arrays - dataset...validation_data : ... validation_data could be: -
tuple
(x_val, y_val) of Numpy arrays or tensors -tuple
(x_val, y_val, val_sample_weights) of Numpy arrays - dataset...
A tuple
(x_val, y_val)
of Numpy arrays or tensors.Numpy arrays 或张量的元组
(x_val, y_val)
。
A tuple(x_val, y_val, val_sample_weights)
of NumPy arrays.NumPy arrays 的元组
(x_val, y_val, val_sample_weights)
。
Reference to a similar question: https://stackoverflow.com/a/63604307/10145479参考类似问题: https://stackoverflow.com/a/63604307/10145479
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.