当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Wiremock: a powerful tool for API testing
- 人工智能学什么课程?它将替代人类工作?
- OPTIMIZER_ Trace details
- Character string and memory operation function in C language
- Every day we say we need to do performance optimization. What are we optimizing?
- 6.4 viewresolver view parser (in-depth analysis of SSM and project practice)
- 快快使用ModelArts,零基础小白也能玩转AI!
- ES6 essence:
- [C / C + + 1] clion configuration and running C language
- 使用 Iceberg on Kubernetes 打造新一代云原生数据湖
猜你喜欢
随机推荐
Just now, I popularized two unique skills of login to Xuemei
[event center azure event hub] interpretation of error information found in event hub logs
Do not understand UML class diagram? Take a look at this edition of rural love class diagram, a learn!
快快使用ModelArts,零基礎小白也能玩轉AI!
业内首发车道级导航背后——详解高精定位技术演进与场景应用
10 easy to use automated testing tools
Python Jieba segmentation (stuttering segmentation), extracting words, loading words, modifying word frequency, defining thesaurus
It's so embarrassing, fans broke ten thousand, used for a year!
如何玩转sortablejs-vuedraggable实现表单嵌套拖拽功能
阿里云Q2营收破纪录背后,云的打开方式正在重塑
Architecture article collection
Let the front-end siege division develop independently from the back-end: Mock.js
Using consult to realize service discovery: instance ID customization
Working principle of gradient descent algorithm in machine learning
Installing the consult cluster
IPFS/Filecoin合法性:保护个人隐私不被泄露
Computer TCP / IP interview 10 even asked, how many can you withstand?
做外包真的很难,身为外包的我也无奈叹息。
This article will introduce you to jest unit test
Every day we say we need to do performance optimization. What are we optimizing?

