未能找到可以处理输入的数据适配器:< class' numpy.ndarray'>,gt; class<
model = Sequential()
model.add(LSTM(1010, input_shape=(x_train.shape[1],x_train.shape[2]), return_sequences=True))
#model2.add(LSTM(128, input_shape=(maxlen, len(chars)),return_sequences=True))
model.add(Dropout(0.1))
model.add(LSTM(100, activation='tanh', return_sequences=True))
model.add(Dropout(0.1))
model.add(LSTM(100, activation='tanh'))
model.add(layers.Dense(101 , activation= 'softmax'))
algorithm = tf.keras.optimizers.Adam(learning_rate=0.001,beta_1=0.9, beta_2=0.999)
model.compile(optimizer=algorithm, loss='categorical_crossentropy', metrics=['acc'])
print(model.summary())
通过考虑类似问题的解决方案,我将y的dtype从float32更改为float64,kfcg_a仅是float64。
print(type(kfcg_a))
print(type(y))
print(kfcg_a.dtype)
print(y.dtype)
它回答
<class 'numpy.ndarray'>
<class 'numpy.ndarray'>
float64
float64
仍然存在错误,无法找到可以处理输入的数据适配器:&lt; class'numpy.ndarray'&gt; ,,&lt; class'int&gt;对于
history=model.fit(kfcg_a,y.shape[1], epochs=100)
tensorflow和keras的版本,我没有得到哪些版本可以兼容解决问题,请合作解决问题。
model = Sequential()
model.add(LSTM(1010, input_shape=(x_train.shape[1],x_train.shape[2]), return_sequences=True))
#model2.add(LSTM(128, input_shape=(maxlen, len(chars)),return_sequences=True))
model.add(Dropout(0.1))
model.add(LSTM(100, activation='tanh', return_sequences=True))
model.add(Dropout(0.1))
model.add(LSTM(100, activation='tanh'))
model.add(layers.Dense(101 , activation= 'softmax'))
algorithm = tf.keras.optimizers.Adam(learning_rate=0.001,beta_1=0.9, beta_2=0.999)
model.compile(optimizer=algorithm, loss='categorical_crossentropy', metrics=['acc'])
print(model.summary())
By considering the solutions for similar questions, I have changed dtype of y from float32 to float64, kfcg_a is of float64 only.
print(type(kfcg_a))
print(type(y))
print(kfcg_a.dtype)
print(y.dtype)
it replied with
<class 'numpy.ndarray'>
<class 'numpy.ndarray'>
float64
float64
still error persists Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, <class 'int'> for model.fit
history=model.fit(kfcg_a,y.shape[1], epochs=100)
is it problem regarding versions of tensorflow and keras, I am not getting which versions are compatible to solve the problem, please cooperate to resolve issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论