Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

#286 Sg/yolox readme

Merged
oferbaratz merged 1 commits into Deci-AI:master from deci-ai:SG/yolox_readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
  1. <!DOCTYPE html>
  2. <html class="writer-html5" lang="en" >
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>super_gradients.training.losses.r_squared_loss &mdash; SuperGradients 1.0 documentation</title>
  7. <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
  8. <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" />
  9. <link rel="stylesheet" href="../../../../_static/graphviz.css" type="text/css" />
  10. <!--[if lt IE 9]>
  11. <script src="../../../../_static/js/html5shiv.min.js"></script>
  12. <![endif]-->
  13. <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
  14. <script src="../../../../_static/jquery.js"></script>
  15. <script src="../../../../_static/underscore.js"></script>
  16. <script src="../../../../_static/doctools.js"></script>
  17. <script src="../../../../_static/js/theme.js"></script>
  18. <link rel="index" title="Index" href="../../../../genindex.html" />
  19. <link rel="search" title="Search" href="../../../../search.html" />
  20. </head>
  21. <body class="wy-body-for-nav">
  22. <div class="wy-grid-for-nav">
  23. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  24. <div class="wy-side-scroll">
  25. <div class="wy-side-nav-search" >
  26. <a href="../../../../index.html" class="icon icon-home"> SuperGradients
  27. </a>
  28. <div role="search">
  29. <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get">
  30. <input type="text" name="q" placeholder="Search docs" />
  31. <input type="hidden" name="check_keywords" value="yes" />
  32. <input type="hidden" name="area" value="default" />
  33. </form>
  34. </div>
  35. </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
  36. <p class="caption"><span class="caption-text">SuperGradients</span></p>
  37. <ul>
  38. <li class="toctree-l1"><a class="reference internal" href="../../../../welcome.html">SuperGradients</a></li>
  39. <li class="toctree-l1"><a class="reference internal" href="../../../../super_gradients.common.html">Common</a></li>
  40. <li class="toctree-l1"><a class="reference internal" href="../../../../super_gradients.training.html">Training</a></li>
  41. </ul>
  42. </div>
  43. </div>
  44. </nav>
  45. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
  46. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  47. <a href="../../../../index.html">SuperGradients</a>
  48. </nav>
  49. <div class="wy-nav-content">
  50. <div class="rst-content">
  51. <div role="navigation" aria-label="Page navigation">
  52. <ul class="wy-breadcrumbs">
  53. <li><a href="../../../../index.html" class="icon icon-home"></a> &raquo;</li>
  54. <li><a href="../../../index.html">Module code</a> &raquo;</li>
  55. <li>super_gradients.training.losses.r_squared_loss</li>
  56. <li class="wy-breadcrumbs-aside">
  57. </li>
  58. </ul>
  59. <hr/>
  60. </div>
  61. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  62. <div itemprop="articleBody">
  63. <h1>Source code for super_gradients.training.losses.r_squared_loss</h1><div class="highlight"><pre>
  64. <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>
  65. <span class="kn">import</span> <span class="nn">torch</span>
  66. <span class="kn">import</span> <span class="nn">torch.nn</span> <span class="k">as</span> <span class="nn">nn</span>
  67. <span class="kn">from</span> <span class="nn">torch.nn.modules.loss</span> <span class="kn">import</span> <span class="n">_Loss</span>
  68. <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>
  69. <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>
  70. <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>
  71. <span class="c1"># FIXME - THIS NEEDS TO BE CHANGED SUCH THAT THIS CLASS INHERETS FROM _Loss (TAKE A LOOK AT YoLoV3DetectionLoss)</span>
  72. <span class="sd">&quot;&quot;&quot;Computes the R-squared for the output and target values</span>
  73. <span class="sd"> :param output: Tensor / Numpy / List</span>
  74. <span class="sd"> The prediction</span>
  75. <span class="sd"> :param target: Tensor / Numpy / List</span>
  76. <span class="sd"> The corresponding lables</span>
  77. <span class="sd"> &quot;&quot;&quot;</span>
  78. <span class="c1"># Convert to tensor</span>
  79. <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>
  80. <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>
  81. <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>
  82. <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>
  83. </pre></div>
  84. </div>
  85. </div>
  86. <footer>
  87. <hr/>
  88. <div role="contentinfo">
  89. <p>&#169; Copyright 2021, SuperGradients team.</p>
  90. </div>
  91. Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
  92. <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
  93. provided by <a href="https://readthedocs.org">Read the Docs</a>.
  94. </footer>
  95. </div>
  96. </div>
  97. </section>
  98. </div>
  99. <script>
  100. jQuery(function () {
  101. SphinxRtdTheme.Navigation.enable(true);
  102. });
  103. </script>
  104. </body>
  105. </html>
Discard
Tip!

Press p or to see the previous file or, n or to see the next file