使用TensorFlow,我的模型的准确性为0,我该怎么办?
首先,我只想澄清一下我是AI的初学者,而且我从未使用过TensorFlow。
因此,基本上我想制作一个可以根据13个功能预测评论的AI,这就是我实施它的方式:
inputs = tf.keras.Input(shape=(13,))
x = tf.keras.layers.Dense(64, activation='relu')(inputs)
x = tf.keras.layers.Dense(64, activation='relu')(x)
outputs = tf.keras.layers.Dense(1, activation='sigmoid')(x)
model = tf.keras.Model(inputs, outputs)
model.compile(
optimizer='adam',
loss= tf.keras.losses.MeanSquaredError(),
metrics=[tf.keras.metrics.AUC(name='auc')]
)
batch_size = 32
epochs = 30
history = model.fit(
X_train,
y_train,
validation_split=0.2,
batch_size = batch_size,
epochs = epochs,
callbacks=[tf.keras.callbacks.ReduceLROnPlateau()],
verbose=0,
)
deepLearningEv = model.evaluate(X_test, y_test)
prediction = model.predict(X_test)
,我所有的预测都是1,我在做什么错?
First of all, I just want to clarify that I'm a beginner with AI and I've never used TensorFlow.
So basically I want to make an AI that can predict the Critic_Score based on 13 features and this is the way I implemented it:
inputs = tf.keras.Input(shape=(13,))
x = tf.keras.layers.Dense(64, activation='relu')(inputs)
x = tf.keras.layers.Dense(64, activation='relu')(x)
outputs = tf.keras.layers.Dense(1, activation='sigmoid')(x)
model = tf.keras.Model(inputs, outputs)
model.compile(
optimizer='adam',
loss= tf.keras.losses.MeanSquaredError(),
metrics=[tf.keras.metrics.AUC(name='auc')]
)
batch_size = 32
epochs = 30
history = model.fit(
X_train,
y_train,
validation_split=0.2,
batch_size = batch_size,
epochs = epochs,
callbacks=[tf.keras.callbacks.ReduceLROnPlateau()],
verbose=0,
)
deepLearningEv = model.evaluate(X_test, y_test)
prediction = model.predict(X_test)
And all my predictions are 1, what am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题几乎可以肯定在于您的输出功能。
您使用的Sigmoid函数可以在0到1之间创建值,这是
我建议您查看以下资源。
“ Sigmoid - 这会导致0到1之间的值,我们可以推断出该示例中的示例是多么自信”,取自 在这里
,因此,只有1个预测可能意味着1该模型希望预测更高的价值,但不能预测。另外,很高的MEA也暗示了这种情况。
The problem lies almost certainly in your output function.
The sigmoid function you use can create values between 0 and 1 which is
I would advise you to take a look at the following resources.
"Sigmoid — This results in a value between 0 and 1 which we can infer to be how confident the model is of the example being in the class", taken from here
So in your case, only predictions of 1 could mean, that the model wants to predict higher values but can't. Also, the very high MEA hints at that being the case as well.