Thank you! We'll be in touch ASAP.
Something went wrong, please try again or contact us directly at contact@dagshub.com
Deci-AI:master
deci-ai:SG/yolox_readme
<!DOCTYPE html> <html class="writer-html5" lang="en" > <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>super_gradients.training.losses.r_squared_loss — SuperGradients 1.0 documentation</title> <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" /> <link rel="stylesheet" href="../../../../_static/graphviz.css" type="text/css" /> <!--[if lt IE 9]> <script src="../../../../_static/js/html5shiv.min.js"></script> <![endif]--> <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script> <script src="../../../../_static/jquery.js"></script> <script src="../../../../_static/underscore.js"></script> <script src="../../../../_static/doctools.js"></script> <script src="../../../../_static/js/theme.js"></script> <link rel="index" title="Index" href="../../../../genindex.html" /> <link rel="search" title="Search" href="../../../../search.html" /> </head> <body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > <a href="../../../../index.html" class="icon icon-home"> SuperGradients </a> <div role="search"> <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu"> <p class="caption"><span class="caption-text">SuperGradients</span></p> <ul> <li class="toctree-l1"><a class="reference internal" href="../../../../welcome.html">SuperGradients</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../super_gradients.common.html">Common</a></li> <li class="toctree-l1"><a class="reference internal" href="../../../../super_gradients.training.html">Training</a></li> </ul> </div> </div> </nav> <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" > <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="../../../../index.html">SuperGradients</a> </nav> <div class="wy-nav-content"> <div class="rst-content"> <div role="navigation" aria-label="Page navigation"> <ul class="wy-breadcrumbs"> <li><a href="../../../../index.html" class="icon icon-home"></a> »</li> <li><a href="../../../index.html">Module code</a> »</li> <li>super_gradients.training.losses.r_squared_loss</li> <li class="wy-breadcrumbs-aside"> </li> </ul> <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> <h1>Source code for super_gradients.training.losses.r_squared_loss</h1><div class="highlight"><pre> <span></span><span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">print_function</span><span class="p">,</span> <span class="n">absolute_import</span> <span class="kn">import</span> <span class="nn">torch</span> <span class="kn">import</span> <span class="nn">torch.nn</span> <span class="k">as</span> <span class="nn">nn</span> <span class="kn">from</span> <span class="nn">torch.nn.modules.loss</span> <span class="kn">import</span> <span class="n">_Loss</span> <span class="kn">from</span> <span class="nn">super_gradients.training.utils</span> <span class="kn">import</span> <span class="n">convert_to_tensor</span> <div class="viewcode-block" id="RSquaredLoss"><a class="viewcode-back" href="../../../../super_gradients.training.losses.html#super_gradients.training.losses.r_squared_loss.RSquaredLoss">[docs]</a><span class="k">class</span> <span class="nc">RSquaredLoss</span><span class="p">(</span><span class="n">_Loss</span><span class="p">):</span> <div class="viewcode-block" id="RSquaredLoss.forward"><a class="viewcode-back" href="../../../../super_gradients.training.losses.html#super_gradients.training.losses.r_squared_loss.RSquaredLoss.forward">[docs]</a> <span class="k">def</span> <span class="nf">forward</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output</span><span class="p">,</span> <span class="n">target</span><span class="p">):</span> <span class="c1"># FIXME - THIS NEEDS TO BE CHANGED SUCH THAT THIS CLASS INHERETS FROM _Loss (TAKE A LOOK AT YoLoV3DetectionLoss)</span> <span class="sd">"""Computes the R-squared for the output and target values</span> <span class="sd"> :param output: Tensor / Numpy / List</span> <span class="sd"> The prediction</span> <span class="sd"> :param target: Tensor / Numpy / List</span> <span class="sd"> The corresponding lables</span> <span class="sd"> """</span> <span class="c1"># Convert to tensor</span> <span class="n">output</span> <span class="o">=</span> <span class="n">convert_to_tensor</span><span class="p">(</span><span class="n">output</span><span class="p">)</span> <span class="n">target</span> <span class="o">=</span> <span class="n">convert_to_tensor</span><span class="p">(</span><span class="n">target</span><span class="p">)</span> <span class="n">criterion_mse</span> <span class="o">=</span> <span class="n">nn</span><span class="o">.</span><span class="n">MSELoss</span><span class="p">()</span> <span class="k">return</span> <span class="mi">1</span> <span class="o">-</span> <span class="n">criterion_mse</span><span class="p">(</span><span class="n">output</span><span class="p">,</span> <span class="n">target</span><span class="p">)</span><span class="o">.</span><span class="n">item</span><span class="p">()</span> <span class="o">/</span> <span class="n">torch</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="n">target</span><span class="p">)</span><span class="o">.</span><span class="n">item</span><span class="p">()</span></div></div> </pre></div> </div> </div> <footer> <hr/> <div role="contentinfo"> <p>© Copyright 2021, SuperGradients team.</p> </div> Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. </footer> </div> </div> </section> </div> <script> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); </script> </body> </html>
Press p or to see the previous file or, n or to see the next file