Skip to content

Commit

Permalink
deploy: 4aa5a73
Browse files Browse the repository at this point in the history
  • Loading branch information
Demirrr committed Nov 26, 2024
1 parent 60f16c1 commit db3851c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
25 changes: 20 additions & 5 deletions _modules/dicee/models/ensemble.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ <h1>Source code for dicee.models.ensemble</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">loss_history</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">cuda</span><span class="o">.</span><span class="n">device_count</span><span class="p">()):</span>
<span class="n">i_model</span><span class="o">=</span><span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">seed_model</span><span class="p">)</span>
<span class="n">i_model</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">device</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;cuda:</span><span class="si">{</span><span class="n">i</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">))</span>
<span class="c1"># TODO: Why we cant send the compile model to cpu ?</span>
<span class="c1"># i_model = torch.compile(i_model)</span>
<span class="n">i_model</span> <span class="o">=</span> <span class="n">torch</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="n">i_model</span><span class="p">)</span>
<span class="n">i_model</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="n">torch</span><span class="o">.</span><span class="n">device</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;cuda:</span><span class="si">{</span><span class="n">i</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">))</span>
<span class="bp">self</span><span class="o">.</span><span class="n">optimizers</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i_model</span><span class="o">.</span><span class="n">configure_optimizers</span><span class="p">())</span>
<span class="bp">self</span><span class="o">.</span><span class="n">models</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i_model</span><span class="p">)</span>
<span class="c1"># Maybe use the original model&#39;s name ?</span>
<span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="o">=</span><span class="s2">&quot;TP_&quot;</span><span class="o">+</span><span class="bp">self</span><span class="o">.</span><span class="n">models</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">name</span>
<span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">models</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">name</span>
<span class="bp">self</span><span class="o">.</span><span class="n">train_mode</span><span class="o">=</span><span class="kc">True</span>

<div class="viewcode-block" id="EnsembleKGE.named_children">
Expand Down Expand Up @@ -208,9 +208,24 @@ <h1>Source code for dicee.models.ensemble</h1><div class="highlight"><pre>
<div class="viewcode-block" id="EnsembleKGE.get_embeddings">
<a class="viewcode-back" href="../../../autoapi/dicee/models/ensemble/index.html#dicee.EnsembleKGE.get_embeddings">[docs]</a>
<span class="k">def</span> <span class="nf">get_embeddings</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">(</span><span class="s2">&quot;Not yet Implemented&quot;</span><span class="p">)</span></div>
<span class="n">entity_embeddings</span><span class="o">=</span><span class="p">[]</span>
<span class="n">relation_embeddings</span><span class="o">=</span><span class="p">[]</span>
<span class="c1"># () Iterate</span>
<span class="k">for</span> <span class="n">trained_model</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">models</span><span class="p">:</span>
<span class="n">entity_emb</span><span class="p">,</span> <span class="n">relation_ebm</span> <span class="o">=</span> <span class="n">trained_model</span><span class="o">.</span><span class="n">get_embeddings</span><span class="p">()</span>
<span class="n">entity_embeddings</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">entity_emb</span><span class="p">)</span>
<span class="k">if</span> <span class="n">relation_ebm</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">relation_embeddings</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">relation_ebm</span><span class="p">)</span>
<span class="c1"># () Concat the embedding vectors horizontally.</span>
<span class="n">entity_embeddings</span><span class="o">=</span><span class="n">torch</span><span class="o">.</span><span class="n">cat</span><span class="p">(</span><span class="n">entity_embeddings</span><span class="p">,</span><span class="n">dim</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="k">if</span> <span class="n">relation_embeddings</span><span class="p">:</span>
<span class="n">relation_embeddings</span><span class="o">=</span><span class="n">torch</span><span class="o">.</span><span class="n">cat</span><span class="p">(</span><span class="n">relation_embeddings</span><span class="p">,</span><span class="n">dim</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">relation_embeddings</span><span class="o">=</span><span class="kc">None</span>

<span class="k">return</span> <span class="n">entity_embeddings</span><span class="p">,</span> <span class="n">relation_embeddings</span></div>


<span class="w"> </span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> def __getattr__(self, name):</span>
<span class="sd"> # Create a function that will call the same attribute/method on each model</span>
Expand Down
2 changes: 0 additions & 2 deletions _sources/autoapi/dicee/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2048,8 +2048,6 @@ Package Contents
.. py:method:: get_embeddings()
:abstractmethod:

.. py:method:: __str__()
Expand Down
2 changes: 0 additions & 2 deletions _sources/autoapi/dicee/models/ensemble/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ Module Contents
.. py:method:: get_embeddings()
:abstractmethod:

.. py:method:: __str__()
Expand Down
2 changes: 1 addition & 1 deletion autoapi/dicee/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3262,7 +3262,7 @@ <h3>Output<a class="headerlink" href="#id9" title="Link to this heading"></a>

<dl class="py method">
<dt class="sig sig-object py" id="dicee.EnsembleKGE.get_embeddings">
<em class="property"><span class="pre">abstract</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">get_embeddings</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/dicee/models/ensemble.html#EnsembleKGE.get_embeddings"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dicee.EnsembleKGE.get_embeddings" title="Link to this definition"></a></dt>
<span class="sig-name descname"><span class="pre">get_embeddings</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/dicee/models/ensemble.html#EnsembleKGE.get_embeddings"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dicee.EnsembleKGE.get_embeddings" title="Link to this definition"></a></dt>
<dd></dd></dl>

<dl class="py method">
Expand Down
2 changes: 1 addition & 1 deletion autoapi/dicee/models/ensemble/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ <h2>Module Contents<a class="headerlink" href="#module-contents" title="Link to

<dl class="py method">
<dt class="sig sig-object py" id="dicee.models.ensemble.EnsembleKGE.get_embeddings">
<em class="property"><span class="pre">abstract</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">get_embeddings</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../../../_modules/dicee/models/ensemble.html#EnsembleKGE.get_embeddings"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dicee.models.ensemble.EnsembleKGE.get_embeddings" title="Link to this definition"></a></dt>
<span class="sig-name descname"><span class="pre">get_embeddings</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../../../_modules/dicee/models/ensemble.html#EnsembleKGE.get_embeddings"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dicee.models.ensemble.EnsembleKGE.get_embeddings" title="Link to this definition"></a></dt>
<dd></dd></dl>

<dl class="py method">
Expand Down
Binary file modified diceembeddings.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit db3851c

Please sign in to comment.