- Reinforcement Learning with TensorFlow
- Sayon Dutta
- 263字
- 2021-08-27 18:51:53
The cost function
The cost function is a metric that determines how well or poorly a machine learning algorithm performed with regards to the actual training output and the predicted output. If you remember linear regression, where the sum of squares of errors was used as the loss function, that is, . This works better in a convex curve, but in the case of classification, the curve is non convex; as a result, the gradient descent doesn't work well and doesn't tend to global optimum. Therefore, we use cross-entropy loss which fits better in classification tasks as the cost function.


Thus, cost function = Average cross entropy loss (for the whole dataset), that is,

In case of binary logistic regression, output classes are only two, that is, 0 and 1, since the sum of class values will always be 1. Therefore (for input data), if one class is
, the other will be
. Similarly, since the probability of class
is
(prediction), then the probability of the other class, that is,
, will be
.
Therefore, the loss function modifies to , where:
If
, that is,
= -
. Therefore, to minimize
,
should be large, that is, closer to 1.
If
, that is,
= -
. Therefore, to minimize
,
should be small, that is, closer to 0.
Loss function applies to a single example whereas cost function applies on the whole training lot. Thus, the cost function for this case will be:
- Clojure Data Analysis Cookbook
- Splunk 7 Essentials(Third Edition)
- Visual C# 2008開發(fā)技術(shù)實(shí)例詳解
- Hadoop Real-World Solutions Cookbook(Second Edition)
- Photoshop CS3圖像處理融會貫通
- ESP8266 Home Automation Projects
- 人工智能實(shí)踐錄
- 我也能做CTO之程序員職業(yè)規(guī)劃
- 數(shù)據(jù)掘金
- WOW!Photoshop CS6完全自學(xué)寶典
- 計算機(jī)應(yīng)用基礎(chǔ)實(shí)訓(xùn)(職業(yè)模塊)
- 工業(yè)機(jī)器人操作
- 機(jī)器人制作入門(第4版)
- 網(wǎng)站規(guī)劃與網(wǎng)頁設(shè)計
- 教育創(chuàng)新與創(chuàng)新人才:信息技術(shù)人才培養(yǎng)改革之路(四)