|
74 | 74 | </div> |
75 | 75 | <div class='code'> |
76 | 76 | <div class="highlight"><pre><span class="lineno">1</span><span></span><span class="kn">import</span> <span class="nn">torch</span> |
77 | | -<span class="lineno">2</span><span class="kn">from</span> <span class="nn">torch</span> <span class="kn">import</span> <span class="n">nn</span> |
78 | | -<span class="lineno">3</span> |
79 | | -<span class="lineno">4</span><span class="kn">from</span> <span class="nn">labml_helpers.module</span> <span class="kn">import</span> <span class="n">Module</span></pre></div> |
| 77 | +<span class="lineno">2</span><span class="kn">from</span> <span class="nn">torch</span> <span class="kn">import</span> <span class="n">nn</span></pre></div> |
80 | 78 | </div> |
81 | 79 | </div> |
82 | 80 | <div class='section' id='section-1'> |
|
87 | 85 |
|
88 | 86 | </div> |
89 | 87 | <div class='code'> |
90 | | - <div class="highlight"><pre><span class="lineno">7</span><span class="k">class</span> <span class="nc">Swish</span><span class="p">(</span><span class="n">Module</span><span class="p">):</span></pre></div> |
| 88 | + <div class="highlight"><pre><span class="lineno">6</span><span class="k">class</span> <span class="nc">Swish</span><span class="p">(</span><span class="n">nn</span><span class="o">.</span><span class="n">Module</span><span class="p">):</span></pre></div> |
91 | 89 | </div> |
92 | 90 | </div> |
93 | 91 | <div class='section' id='section-2'> |
|
98 | 96 |
|
99 | 97 | </div> |
100 | 98 | <div class='code'> |
101 | | - <div class="highlight"><pre><span class="lineno">8</span> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> |
102 | | -<span class="lineno">9</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span> |
103 | | -<span class="lineno">10</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigmoid</span> <span class="o">=</span> <span class="n">nn</span><span class="o">.</span><span class="n">Sigmoid</span><span class="p">()</span></pre></div> |
| 99 | + <div class="highlight"><pre><span class="lineno">7</span> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> |
| 100 | +<span class="lineno">8</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span> |
| 101 | +<span class="lineno">9</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigmoid</span> <span class="o">=</span> <span class="n">nn</span><span class="o">.</span><span class="n">Sigmoid</span><span class="p">()</span></pre></div> |
104 | 102 | </div> |
105 | 103 | </div> |
106 | 104 | <div class='section' id='section-3'> |
|
111 | 109 |
|
112 | 110 | </div> |
113 | 111 | <div class='code'> |
114 | | - <div class="highlight"><pre><span class="lineno">12</span> <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">x</span><span class="p">:</span> <span class="n">torch</span><span class="o">.</span><span class="n">Tensor</span><span class="p">)</span> <span class="o">-></span> <span class="n">torch</span><span class="o">.</span><span class="n">Tensor</span><span class="p">:</span> |
115 | | -<span class="lineno">13</span> <span class="k">return</span> <span class="n">x</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigmoid</span><span class="p">(</span><span class="n">x</span><span class="p">)</span></pre></div> |
| 112 | + <div class="highlight"><pre><span class="lineno">11</span> <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">x</span><span class="p">:</span> <span class="n">torch</span><span class="o">.</span><span class="n">Tensor</span><span class="p">)</span> <span class="o">-></span> <span class="n">torch</span><span class="o">.</span><span class="n">Tensor</span><span class="p">:</span> |
| 113 | +<span class="lineno">12</span> <span class="k">return</span> <span class="n">x</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigmoid</span><span class="p">(</span><span class="n">x</span><span class="p">)</span></pre></div> |
116 | 114 | </div> |
117 | 115 | </div> |
118 | 116 | <div class='footer'> |
|
0 commit comments