Skip to content

Commit

Permalink
AlCatt91 published a site update
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCatt91 committed Jan 23, 2024
1 parent b28953d commit d94b2f7
Show file tree
Hide file tree
Showing 19 changed files with 214 additions and 14 deletions.
16 changes: 16 additions & 0 deletions _modules/besskge/embedding.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,22 @@ <h1>Source code for besskge.embedding</h1><div class="highlight"><pre>
<span class="p">)</span></div>


<div class="viewcode-block" id="init_uniform_rotation"><a class="viewcode-back" href="../../generated/besskge.embedding.init_uniform_rotation.html#besskge.embedding.init_uniform_rotation">[docs]</a><span class="k">def</span> <span class="nf">init_uniform_rotation</span><span class="p">(</span><span class="n">embedding_table</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">-&gt;</span> <span class="n">torch</span><span class="o">.</span><span class="n">Tensor</span><span class="p">:</span>
<span class="w"> </span><span class="sa">r</span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Initialize tensor with each entry being a uniformly distributed</span>
<span class="sd"> phase between 0 and :math:`2 \pi`.</span>
<span class="sd"> To be used for initialization of relation embedding tables</span>
<span class="sd"> in RotatE scoring function.</span>

<span class="sd"> :param embedding_table:</span>
<span class="sd"> Tensor of embedding parameters to initialize.</span>

<span class="sd"> :return:</span>
<span class="sd"> Initialized tensor.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">torch</span><span class="o">.</span><span class="n">rand_like</span><span class="p">(</span><span class="n">embedding_table</span><span class="p">)</span> <span class="o">*</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span></div>


<div class="viewcode-block" id="init_KGE_uniform"><a class="viewcode-back" href="../../generated/besskge.embedding.init_KGE_uniform.html#besskge.embedding.init_KGE_uniform">[docs]</a><span class="k">def</span> <span class="nf">init_KGE_uniform</span><span class="p">(</span>
<span class="n">embedding_table</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="n">b</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">1.0</span><span class="p">,</span> <span class="n">divide_by_embedding_size</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">torch</span><span class="o">.</span><span class="n">Tensor</span><span class="p">:</span>
Expand Down
3 changes: 2 additions & 1 deletion _modules/besskge/scoring.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ <h1>Source code for besskge.scoring</h1><div class="highlight"><pre>
<span class="n">init_KGE_normal</span><span class="p">,</span>
<span class="n">init_KGE_uniform</span><span class="p">,</span>
<span class="n">init_uniform_norm</span><span class="p">,</span>
<span class="n">init_uniform_rotation</span><span class="p">,</span>
<span class="n">init_xavier_norm</span><span class="p">,</span>
<span class="n">initialize_entity_embedding</span><span class="p">,</span>
<span class="n">initialize_relation_embedding</span><span class="p">,</span>
Expand Down Expand Up @@ -443,7 +444,7 @@ <h1>Source code for besskge.scoring</h1><div class="highlight"><pre>
<span class="n">init_KGE_uniform</span>
<span class="p">],</span>
<span class="n">relation_initializer</span><span class="p">:</span> <span class="n">Union</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="n">List</span><span class="p">[</span><span class="n">Callable</span><span class="p">[</span><span class="o">...</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="p">[</span>
<span class="n">init_KGE_uniform</span>
<span class="n">init_uniform_rotation</span>
<span class="p">],</span>
<span class="n">inverse_relations</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
besskge.embedding.init\_uniform\_rotation
=========================================

.. currentmodule:: besskge.embedding

.. autofunction:: init_uniform_rotation
1 change: 1 addition & 0 deletions _sources/generated/besskge.embedding.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ besskge.embedding
init_KGE_normal
init_KGE_uniform
init_uniform_norm
init_uniform_rotation
init_xavier_norm
initialize_entity_embedding
initialize_relation_embedding
Expand Down
4 changes: 2 additions & 2 deletions generated/besskge.dataset.KGDataset.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ <h1>besskge.dataset.KGDataset<a class="headerlink" href="#besskge-dataset-kgdata
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>df</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Union" title="(in Python v3.12)"><code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code></a>[<a class="reference external" href="http://pandas.pydata.org/pandas-docs/dev/reference/api/pandas.DataFrame.html#pandas.DataFrame" title="(in pandas v2.3.0.dev0+54.g04b45b10b1)"><code class="xref py py-class docutils literal notranslate"><span class="pre">DataFrame</span></code></a>, <a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Dict" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">Dict</span></code></a>[<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>, <a class="reference external" href="http://pandas.pydata.org/pandas-docs/dev/reference/api/pandas.DataFrame.html#pandas.DataFrame" title="(in pandas v2.3.0.dev0+54.g04b45b10b1)"><code class="xref py py-class docutils literal notranslate"><span class="pre">DataFrame</span></code></a>]]) – Pandas DataFrame of all triples in the knowledge graph dataset,
<li><p><strong>df</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Union" title="(in Python v3.12)"><code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code></a>[<a class="reference external" href="http://pandas.pydata.org/pandas-docs/dev/reference/api/pandas.DataFrame.html#pandas.DataFrame" title="(in pandas v3.0.0.dev0+163.g7281475054)"><code class="xref py py-class docutils literal notranslate"><span class="pre">DataFrame</span></code></a>, <a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Dict" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">Dict</span></code></a>[<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>, <a class="reference external" href="http://pandas.pydata.org/pandas-docs/dev/reference/api/pandas.DataFrame.html#pandas.DataFrame" title="(in pandas v3.0.0.dev0+163.g7281475054)"><code class="xref py py-class docutils literal notranslate"><span class="pre">DataFrame</span></code></a>]]) – Pandas DataFrame of all triples in the knowledge graph dataset,
or dictionary of DataFrames of triples for each part of the dataset split</p></li>
<li><p><strong>head_column</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Union" title="(in Python v3.12)"><code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code></a>[<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>, <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>]) – Name of the DataFrame column storing head entities</p></li>
<li><p><strong>relation_column</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Union" title="(in Python v3.12)"><code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code></a>[<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>, <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>]) – Name of the DataFrame column storing relations</p></li>
<li><p><strong>tail_column</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Union" title="(in Python v3.12)"><code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code></a>[<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>, <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>]) – Name of the DataFrame column storing tail entities</p></li>
<li><p><strong>entity_types</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Union" title="(in Python v3.12)"><code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code></a>[<a class="reference external" href="http://pandas.pydata.org/pandas-docs/dev/reference/api/pandas.Series.html#pandas.Series" title="(in pandas v2.3.0.dev0+54.g04b45b10b1)"><code class="xref py py-class docutils literal notranslate"><span class="pre">Series</span></code></a>, <a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Dict" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">Dict</span></code></a>[<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>, <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>], <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.12)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a>]) – If entities have types, dictionary or pandas Series of mappings
<li><p><strong>entity_types</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Union" title="(in Python v3.12)"><code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code></a>[<a class="reference external" href="http://pandas.pydata.org/pandas-docs/dev/reference/api/pandas.Series.html#pandas.Series" title="(in pandas v3.0.0.dev0+163.g7281475054)"><code class="xref py py-class docutils literal notranslate"><span class="pre">Series</span></code></a>, <a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Dict" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">Dict</span></code></a>[<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>, <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>], <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.12)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a>]) – If entities have types, dictionary or pandas Series of mappings
entity label -&gt; entity type (as strings).</p></li>
<li><p><strong>split</strong> (<a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.Tuple" title="(in Python v3.12)"><code class="xref py py-data docutils literal notranslate"><span class="pre">Tuple</span></code></a>[<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code></a>, <a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code></a>, <a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">float</span></code></a>]) – Tuple to set the train/validation/test split.
Only used if no pre-defined dataset split is specified,
Expand Down
13 changes: 9 additions & 4 deletions generated/besskge.embedding.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/sphinx_highlight.js"></script>
<script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.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" />
Expand Down Expand Up @@ -59,6 +60,7 @@
<li class="toctree-l3"><a class="reference internal" href="besskge.embedding.init_KGE_normal.html">besskge.embedding.init_KGE_normal</a></li>
<li class="toctree-l3"><a class="reference internal" href="besskge.embedding.init_KGE_uniform.html">besskge.embedding.init_KGE_uniform</a></li>
<li class="toctree-l3"><a class="reference internal" href="besskge.embedding.init_uniform_norm.html">besskge.embedding.init_uniform_norm</a></li>
<li class="toctree-l3"><a class="reference internal" href="besskge.embedding.init_uniform_rotation.html">besskge.embedding.init_uniform_rotation</a></li>
<li class="toctree-l3"><a class="reference internal" href="besskge.embedding.init_xavier_norm.html">besskge.embedding.init_xavier_norm</a></li>
<li class="toctree-l3"><a class="reference internal" href="besskge.embedding.initialize_entity_embedding.html">besskge.embedding.initialize_entity_embedding</a></li>
<li class="toctree-l3"><a class="reference internal" href="besskge.embedding.initialize_relation_embedding.html">besskge.embedding.initialize_relation_embedding</a></li>
Expand Down Expand Up @@ -112,16 +114,19 @@
<tr class="row-odd"><td><p><a class="reference internal" href="besskge.embedding.init_uniform_norm.html#besskge.embedding.init_uniform_norm" title="besskge.embedding.init_uniform_norm"><code class="xref py py-obj docutils literal notranslate"><span class="pre">init_uniform_norm</span></code></a>(embedding_table)</p></td>
<td><p>Initialize embeddings according to uniform distribution and normalize so that each row has norm 1.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="besskge.embedding.init_xavier_norm.html#besskge.embedding.init_xavier_norm" title="besskge.embedding.init_xavier_norm"><code class="xref py py-obj docutils literal notranslate"><span class="pre">init_xavier_norm</span></code></a>(embedding_table[, gain])</p></td>
<tr class="row-even"><td><p><a class="reference internal" href="besskge.embedding.init_uniform_rotation.html#besskge.embedding.init_uniform_rotation" title="besskge.embedding.init_uniform_rotation"><code class="xref py py-obj docutils literal notranslate"><span class="pre">init_uniform_rotation</span></code></a>(embedding_table)</p></td>
<td><p>Initialize tensor with each entry being a uniformly distributed phase between 0 and <span class="math notranslate nohighlight">\(2 \pi\)</span>.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="besskge.embedding.init_xavier_norm.html#besskge.embedding.init_xavier_norm" title="besskge.embedding.init_xavier_norm"><code class="xref py py-obj docutils literal notranslate"><span class="pre">init_xavier_norm</span></code></a>(embedding_table[, gain])</p></td>
<td><p>Initialize embeddings according to Xavier normal scheme, with <cite>fan_in = 0</cite>, <cite>fan_out=row_size</cite>.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="besskge.embedding.initialize_entity_embedding.html#besskge.embedding.initialize_entity_embedding" title="besskge.embedding.initialize_entity_embedding"><code class="xref py py-obj docutils literal notranslate"><span class="pre">initialize_entity_embedding</span></code></a>(sharding, ...[, ...])</p></td>
<tr class="row-even"><td><p><a class="reference internal" href="besskge.embedding.initialize_entity_embedding.html#besskge.embedding.initialize_entity_embedding" title="besskge.embedding.initialize_entity_embedding"><code class="xref py py-obj docutils literal notranslate"><span class="pre">initialize_entity_embedding</span></code></a>(sharding, ...[, ...])</p></td>
<td><p>Initialize entity embedding table.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="besskge.embedding.initialize_relation_embedding.html#besskge.embedding.initialize_relation_embedding" title="besskge.embedding.initialize_relation_embedding"><code class="xref py py-obj docutils literal notranslate"><span class="pre">initialize_relation_embedding</span></code></a>(...[, row_size])</p></td>
<tr class="row-odd"><td><p><a class="reference internal" href="besskge.embedding.initialize_relation_embedding.html#besskge.embedding.initialize_relation_embedding" title="besskge.embedding.initialize_relation_embedding"><code class="xref py py-obj docutils literal notranslate"><span class="pre">initialize_relation_embedding</span></code></a>(...[, row_size])</p></td>
<td><p>Initialize relation embedding table.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="besskge.embedding.refactor_embedding_sharding.html#besskge.embedding.refactor_embedding_sharding" title="besskge.embedding.refactor_embedding_sharding"><code class="xref py py-obj docutils literal notranslate"><span class="pre">refactor_embedding_sharding</span></code></a>(...)</p></td>
<tr class="row-even"><td><p><a class="reference internal" href="besskge.embedding.refactor_embedding_sharding.html#besskge.embedding.refactor_embedding_sharding" title="besskge.embedding.refactor_embedding_sharding"><code class="xref py py-obj docutils literal notranslate"><span class="pre">refactor_embedding_sharding</span></code></a>(...)</p></td>
<td><p>Refactor sharded entity embedding table to pass from one entity sharding to a different one.</p></td>
</tr>
</tbody>
Expand Down
Loading

0 comments on commit d94b2f7

Please sign in to comment.