当前位置:网站首页>keras model.compile Loss function and optimizer
keras model.compile Loss function and optimizer
2020-11-06 01:22:00 【Elementary school students in IT field】
Loss function
summary
Loss function is the goal of model optimization , So it's also called objective function 、 Optimize the scoring function , stay keras in , Parameters for model compilation loss Class of loss function specified , There are two ways of specifying :
model.compile(loss='mean_squared_error', optimizer='sgd')
perhaps
from keras import losses
model.compile(loss=losses.mean_squared_error, optimizer='sgd')
Available loss function
Available loss objective function :
mean_squared_error or mse
mean_absolute_error or mae
mean_absolute_percentage_error or mape
mean_squared_logarithmic_error or msle
squared_hinge
hinge
categorical_hinge
binary_crossentropy( Also called logarithmic loss ,logloss)
logcosh
categorical_crossentropy: Also known as multi class logarithmic loss , Note when using this objective function , The label needs to be transformed into a shape like (nb_samples, nb_classes) Binary sequence of
sparse_categorical_crossentrop: Above , But accept sparse tags . Be careful , When using this function, you still need to have the same dimension as the output value , You may need to add a dimension to the tag data :np.expand_dims(y,-1)
kullback_leibler_divergence: From the probability distribution of predicted values Q To the truth probability distribution P Information gain of , To measure the difference between two distributions .
poisson: namely (predictions - targets * log(predictions)) The average of
cosine_proximity: That is, the inverse number between the predicted value and the average cosine distance of the real label
Loss function formula
https://zhuanlan.zhihu.com/p/34667893
Two classification - Report errors
On the loss function of the report error :
use Keras Do text classification , I always have mistakes like this ,
My category is 0 or 1, But the mistake told me it couldn't be 1.
See :Received a label value of 1 which is outside the valid range of [0, 1) - Python, Keras
loss function The problem of .
It used to be sparse_categorical_crossentropy,
Change it to binary_crossentropy Problem solving .
Optimizer
https://www.cnblogs.com/xiaobingqianrui/p/10756046.html
版权声明
本文为[Elementary school students in IT field]所创,转载请带上原文链接,感谢
边栏推荐
- Skywalking series blog 1 - install stand-alone skywalking
- 6.3 handlerexceptionresolver exception handling (in-depth analysis of SSM and project practice)
- 向北京集结!OpenI/O 2020启智开发者大会进入倒计时
- This article will introduce you to jest unit test
- How long does it take you to work out an object-oriented programming interview question from Ali school?
- 5.5 controlleradvice notes - SSM in depth analysis and project practice
- I've been rejected by the product manager. Why don't you know
- Skywalking series blog 5-apm-customize-enhance-plugin
- 加速「全民直播」洪流,如何攻克延时、卡顿、高并发难题?
- ES6 essence:
猜你喜欢
业内首发车道级导航背后——详解高精定位技术演进与场景应用
Python download module to accelerate the implementation of recording
Filecoin主网上线以来Filecoin矿机扇区密封到底是什么意思
怎么理解Python迭代器与生成器?
比特币一度突破14000美元,即将面临美国大选考验
Calculation script for time series data
CCR炒币机器人:“比特币”数字货币的大佬,你不得不了解的知识
采购供应商系统是什么?采购供应商管理平台解决方案
DevOps是什么
git rebase的時候捅婁子了,怎麼辦?線上等……
随机推荐
Python + appium automatic operation wechat is enough
[event center azure event hub] interpretation of error information found in event hub logs
6.2 handleradapter adapter processor (in-depth analysis of SSM and project practice)
数字城市响应相关国家政策大力发展数字孪生平台的建设
Filecoin最新动态 完成重大升级 已实现四大项目进展!
Skywalking series blog 2-skywalking using
The choice of enterprise database is usually decided by the system architect - the newstack
From zero learning artificial intelligence, open the road of career planning!
OPTIMIZER_ Trace details
CCR炒币机器人:“比特币”数字货币的大佬,你不得不了解的知识
快快使用ModelArts,零基礎小白也能玩轉AI!
axios学习笔记(二):轻松弄懂XHR的使用及如何封装简易axios
Want to do read-write separation, give you some small experience
Existence judgment in structured data
100元扫货阿里云是怎样的体验?
Summary of common algorithms of binary tree
Linked blocking Queue Analysis of blocking queue
Let the front-end siege division develop independently from the back-end: Mock.js
Grouping operation aligned with specified datum
[C / C + + 1] clion configuration and running C language