使用TensorFlow,我的模型的准确性为0,我该怎么办?

发布于 2025-02-07 20:12:00 字数 920 浏览 2 评论 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)

IMG预测

,我所有的预测都是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)

Img predictions

And all my predictions are 1, what am I doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

⒈起吃苦の倖褔 2025-02-14 20:12:00

问题几乎可以肯定在于您的输出功能。
您使用的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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文