Skip to content

Commit

Permalink
deploy: abc5226
Browse files Browse the repository at this point in the history
  • Loading branch information
Demirrr committed Nov 25, 2024
1 parent db8c396 commit 8b5935d
Show file tree
Hide file tree
Showing 43 changed files with 2,483 additions and 734 deletions.
668 changes: 668 additions & 0 deletions _modules/dicee/models/adopt.html

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions _modules/dicee/models/base_model.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ <h1>Source code for dicee.models.base_model</h1><div class="highlight"><pre>
<span class="kn">import</span> <span class="nn">torch</span>
<span class="kn">from</span> <span class="nn">torch</span> <span class="kn">import</span> <span class="n">nn</span>
<span class="kn">from</span> <span class="nn">torch.nn</span> <span class="kn">import</span> <span class="n">functional</span> <span class="k">as</span> <span class="n">F</span>
<span class="kn">from</span> <span class="nn">.adopt</span> <span class="kn">import</span> <span class="n">ADOPT</span>

<div class="viewcode-block" id="BaseKGELightning">
<a class="viewcode-back" href="../../../autoapi/dicee/models/index.html#dicee.BaseKGELightning">[docs]</a>
Expand Down Expand Up @@ -212,9 +213,12 @@ <h1>Source code for dicee.models.base_model</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">selected_optimizer</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">optim</span><span class="o">.</span><span class="n">SGD</span><span class="p">(</span><span class="n">params</span><span class="o">=</span><span class="n">parameters</span><span class="p">,</span> <span class="n">lr</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">learning_rate</span><span class="p">,</span>
<span class="n">momentum</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">dampening</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">weight_decay</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">weight_decay</span><span class="p">,</span>
<span class="n">nesterov</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>

<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">optimizer_name</span> <span class="o">==</span> <span class="s1">&#39;Adam&#39;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">selected_optimizer</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">optim</span><span class="o">.</span><span class="n">Adam</span><span class="p">(</span><span class="n">parameters</span><span class="p">,</span> <span class="n">lr</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">learning_rate</span><span class="p">,</span>
<span class="n">weight_decay</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">weight_decay</span><span class="p">)</span>
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">optimizer_name</span> <span class="o">==</span> <span class="s1">&#39;Adopt&#39;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">selected_optimizer</span> <span class="o">=</span> <span class="n">ADOPT</span><span class="p">(</span><span class="n">parameters</span><span class="p">,</span> <span class="n">lr</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">learning_rate</span><span class="p">)</span>
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">optimizer_name</span> <span class="o">==</span> <span class="s1">&#39;AdamW&#39;</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">selected_optimizer</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">optim</span><span class="o">.</span><span class="n">AdamW</span><span class="p">(</span><span class="n">parameters</span><span class="p">,</span> <span class="n">lr</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">learning_rate</span><span class="p">,</span>
<span class="n">weight_decay</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">weight_decay</span><span class="p">)</span>
Expand All @@ -230,7 +234,7 @@ <h1>Source code for dicee.models.base_model</h1><div class="highlight"><pre>
<span class="n">lr</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">learning_rate</span><span class="p">,</span> <span class="n">lambd</span><span class="o">=</span><span class="mf">0.0001</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mf">0.75</span><span class="p">,</span>
<span class="n">weight_decay</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">weight_decay</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">KeyError</span><span class="p">()</span>
<span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">optimizer_name</span><span class="si">}</span><span class="s2"> is not found!&quot;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">selected_optimizer</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">selected_optimizer</span></div>
</div>
Expand Down Expand Up @@ -425,10 +429,8 @@ <h1>Source code for dicee.models.base_model</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">normalizer_class</span> <span class="o">=</span> <span class="n">IdentityClass</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;optim&quot;</span><span class="p">)</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;AdamW&#39;</span><span class="p">,</span> <span class="s1">&#39;Adam&#39;</span><span class="p">,</span> <span class="s1">&#39;SGD&#39;</span><span class="p">]:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">optimizer_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">&#39;optim&#39;</span><span class="p">]</span>
<span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">optimizer_name</span> <span class="o">=</span> <span class="s1">&#39;Adam&#39;</span>

<span class="bp">self</span><span class="o">.</span><span class="n">optimizer_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">[</span><span class="s1">&#39;optim&#39;</span><span class="p">]</span>

<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;init_param&quot;</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">param_init</span> <span class="o">=</span> <span class="n">IdentityClass</span>
Expand Down
Loading

0 comments on commit 8b5935d

Please sign in to comment.