python - 如何在tensorflow中设置rmse成本函数

标签 python tensorflow

我在 tensorflow 中有成本函数。

activation = tf.add(tf.mul(X, W), b)
cost = (tf.pow(Y-y_model, 2)) # use sqr error for cost function

我正在尝试 this example .如何将其更改为 rmse 成本函数?

最佳答案

tf.sqrt(tf.reduce_mean(tf.square(tf.subtract(targets, outputs))))

并略微简化(TensorFlow 重载了最重要的运算符):

tf.sqrt(tf.reduce_mean((targets - outputs)**2))

关于python - 如何在tensorflow中设置rmse成本函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33846069/

相关文章:

python - 如何加载和使用 PyTorch (.pth.tar) 模型

python - Kivy Python 鼠标位置

python - 我的脚本无法从网页获取食品店的名称

python-3.x - tensorflow 和 keras - SQS 生产中的快速推理

tensorflow - 使用tf.Estimator时如何控制丢失日志消息的频率

python - 搜索日志,输出匹配前后的行

Python3.6 没有名为 "readability.readability"的模块

c++ - Tensorflow:与共享库的动态链接

python - TensorFlow:Compat 弃用警告

python - TensorFlow 对象检测 API 从对象返回文本