blob: 9e440ca9715063f5dd657b8d08cbd0b712e7e9ba [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Apache Singa: singa::Loss Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Apache Singa
</div>
<div id="projectbrief">A General Distributed Deep Learning Library</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="namespacesinga.html">singa</a></li><li class="navelem"><a class="el" href="classsinga_1_1Loss.html">Loss</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classsinga_1_1Loss-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">singa::Loss Class Reference<span class="mlabels"><span class="mlabel">abstract</span></span></div> </div>
</div><!--header-->
<div class="contents">
<p>The base loss class, which declares the APIs for computing the objective score (loss) for a pair of prediction (from the model) and the target (i.e.
<a href="classsinga_1_1Loss.html#details">More...</a></p>
<p><code>#include &lt;<a class="el" href="loss_8h_source.html">loss.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for singa::Loss:</div>
<div class="dyncontent">
<div class="center"><img src="classsinga_1_1Loss__inherit__graph.png" border="0" usemap="#singa_1_1Loss_inherit__map" alt="Inheritance graph"/></div>
<!-- MAP 0 -->
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ab1ffff2b3ddebd84bd1ea19104e1bba5"><td class="memItemLeft" align="right" valign="top"><a id="ab1ffff2b3ddebd84bd1ea19104e1bba5"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>Setup</b> (const string &amp;conf)</td></tr>
<tr class="separator:ab1ffff2b3ddebd84bd1ea19104e1bba5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afe5a390383602feed7b0adf3a6afb487"><td class="memItemLeft" align="right" valign="top"><a id="afe5a390383602feed7b0adf3a6afb487"></a>
virtual void&#160;</td><td class="memItemRight" valign="bottom"><b>ToDevice</b> (std::shared_ptr&lt; <a class="el" href="classsinga_1_1Device.html">Device</a> &gt; device)</td></tr>
<tr class="separator:afe5a390383602feed7b0adf3a6afb487"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5be3a26d72200fb17ce1b2fa8c866525"><td class="memItemLeft" align="right" valign="top"><a id="a5be3a26d72200fb17ce1b2fa8c866525"></a>
virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsinga_1_1Loss.html#a5be3a26d72200fb17ce1b2fa8c866525">Setup</a> (const LossConf &amp;conf)</td></tr>
<tr class="memdesc:a5be3a26d72200fb17ce1b2fa8c866525"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set meta fields from user configurations. <br /></td></tr>
<tr class="separator:a5be3a26d72200fb17ce1b2fa8c866525"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad8ce9cac8b07719a2dcf2e5a50585f80"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="classsinga_1_1Tensor.html">Tensor</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsinga_1_1Loss.html#ad8ce9cac8b07719a2dcf2e5a50585f80">Forward</a> (int flag, const <a class="el" href="classsinga_1_1Tensor.html">Tensor</a> &amp;prediction, const <a class="el" href="classsinga_1_1Tensor.html">Tensor</a> &amp;target)=0</td></tr>
<tr class="memdesc:ad8ce9cac8b07719a2dcf2e5a50585f80"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compute the loss values for each sample/instance given the prediction and the target. <a href="#ad8ce9cac8b07719a2dcf2e5a50585f80">More...</a><br /></td></tr>
<tr class="separator:ad8ce9cac8b07719a2dcf2e5a50585f80"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7dfd3be50e9f20430604d4adab1664ce"><td class="memItemLeft" align="right" valign="top">float&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsinga_1_1Loss.html#a7dfd3be50e9f20430604d4adab1664ce">Evaluate</a> (int flag, const <a class="el" href="classsinga_1_1Tensor.html">Tensor</a> &amp;prediction, const <a class="el" href="classsinga_1_1Tensor.html">Tensor</a> &amp;target)</td></tr>
<tr class="memdesc:a7dfd3be50e9f20430604d4adab1664ce"><td class="mdescLeft">&#160;</td><td class="mdescRight">Average loss values for all samples in the mini-batch It calls <a class="el" href="classsinga_1_1Loss.html#ad8ce9cac8b07719a2dcf2e5a50585f80" title="Compute the loss values for each sample/instance given the prediction and the target. ">Forward()</a> internally. <a href="#a7dfd3be50e9f20430604d4adab1664ce">More...</a><br /></td></tr>
<tr class="separator:a7dfd3be50e9f20430604d4adab1664ce"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a82a5257979b7111e283b2da846124a08"><td class="memItemLeft" align="right" valign="top"><a id="a82a5257979b7111e283b2da846124a08"></a>
virtual <a class="el" href="classsinga_1_1Tensor.html">Tensor</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classsinga_1_1Loss.html#a82a5257979b7111e283b2da846124a08">Backward</a> ()=0</td></tr>
<tr class="memdesc:a82a5257979b7111e283b2da846124a08"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compute the gradients of the loss values w.r.t. the prediction. <br /></td></tr>
<tr class="separator:a82a5257979b7111e283b2da846124a08"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>The base loss class, which declares the APIs for computing the objective score (loss) for a pair of prediction (from the model) and the target (i.e. </p>
<p>the ground truth). It also computes the gradients of the objective w.r.t. the prediction. It has similar APIs as <a class="el" href="classsinga_1_1Layer.html" title="The base layer class. ">Layer</a>. </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a id="a7dfd3be50e9f20430604d4adab1664ce"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7dfd3be50e9f20430604d4adab1664ce">&#9670;&nbsp;</a></span>Evaluate()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">float singa::Loss::Evaluate </td>
<td>(</td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>flag</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classsinga_1_1Tensor.html">Tensor</a> &amp;&#160;</td>
<td class="paramname"><em>prediction</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classsinga_1_1Tensor.html">Tensor</a> &amp;&#160;</td>
<td class="paramname"><em>target</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Average loss values for all samples in the mini-batch It calls <a class="el" href="classsinga_1_1Loss.html#ad8ce9cac8b07719a2dcf2e5a50585f80" title="Compute the loss values for each sample/instance given the prediction and the target. ">Forward()</a> internally. </p>
<p>The calling pattern should be [Evaluate|Forward] Backward. </p>
</div>
</div>
<a id="ad8ce9cac8b07719a2dcf2e5a50585f80"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad8ce9cac8b07719a2dcf2e5a50585f80">&#9670;&nbsp;</a></span>Forward()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual <a class="el" href="classsinga_1_1Tensor.html">Tensor</a> singa::Loss::Forward </td>
<td>(</td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>flag</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classsinga_1_1Tensor.html">Tensor</a> &amp;&#160;</td>
<td class="paramname"><em>prediction</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classsinga_1_1Tensor.html">Tensor</a> &amp;&#160;</td>
<td class="paramname"><em>target</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Compute the loss values for each sample/instance given the prediction and the target. </p>
<p>Implemented in <a class="el" href="classsinga_1_1SoftmaxCrossEntropy.html#a7dacf1dfecad29db29d942e874f3a8fa">singa::SoftmaxCrossEntropy</a>, and <a class="el" href="classsinga_1_1MSE.html#a1ef0a065a58e39957d6de834cf99e917">singa::MSE</a>.</p>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>/home/moaz/incubator-singa/include/singa/model/<a class="el" href="loss_8h_source.html">loss.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Mon Apr 22 2019 12:27:05 for Apache Singa by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>