Keras MAE和MSE source code
2024-09-06 22:05:20
def mean_squared_error(y_true, y_pred):
if not K.is_tensor(y_pred):
y_pred = K.constant(y_pred)
y_true = K.cast(y_true, y_pred.dtype)
return K.mean(K.square(y_pred - y_true), axis=-1)
def mean_absolute_error(y_true, y_pred):
if not K.is_tensor(y_pred):
y_pred = K.constant(y_pred)
y_true = K.cast(y_true, y_pred.dtype)
return K.mean(K.abs(y_pred - y_true), axis=-1)
def mean_absolute_percentage_error(y_true, y_pred):
if not K.is_tensor(y_pred):
y_pred = K.constant(y_pred)
y_true = K.cast(y_true, y_pred.dtype)
diff = K.abs((y_true - y_pred) / K.clip(K.abs(y_true),
K.epsilon(),
None))
return 100. * K.mean(diff, axis=-1)
def mean_squared_logarithmic_error(y_true, y_pred):
if not K.is_tensor(y_pred):
y_pred = K.constant(y_pred)
y_true = K.cast(y_true, y_pred.dtype)
first_log = K.log(K.clip(y_pred, K.epsilon(), None) + 1.)
second_log = K.log(K.clip(y_true, K.epsilon(), None) + 1.)
return K.mean(K.square(first_log - second_log), axis=-1)
最新文章
- 堆排序算法 java 实现
- ios--个人资料修改
- python post
- VS2010 项目引用了微软企业库,但是编译时提示:未能找到类型或命名空间名称
- 翻阅《数据结构与算法javascript描述》--数组篇
- poj 1005 I Think I Need a Houseboat
- HDU 1274 展开字符串 (递归+string类)
- 用CSS3 做的星体
- JAVA虚拟机环境变量设置
- ecshop和jQuery冲突
- OV2685翻转问题
- [开源]快速构建一个WebApi项目
- python数据类型:字典dict常用操作
- (sort)P1068 分数线划定 洛谷
- opencv之内存存储器——CvMemStorage与CvSeq
- poj1185 [NOI2001炮兵阵地]
- GitHub使用指南之快速入门
- MyEclipse SVN 下面切换用户的解决方案
- .NET Framework 4安装失败
- 将新浪博客里的表情包存入MySQL数据库不完整版本一堆可能用到的散乱代码
热门文章
- VirtualBox主机虚拟机互通
- spring(一) IOC 控制反转 、DI 依赖注入
- if you wanna the rainbow, you have to deal with the rain.
- 7.安装pycharm----导入Nmap模块----netcat反向shell----metasploitable靶机环境
- java基础/java调用shell命令和脚本
- 深入理解java:2.3.2. 并发编程concurrent包 之重入锁/读写锁/条件锁
- [Python3] 042 日志
- js获取url中的参数(解决中文乱码)
- Scrapy 教程(五)-分页策略
- 数学: HDU1005 Number Sequence