Files
D-SCRIPT/docs/build/html/api/dscript.models.html
2021-08-16 20:52:51 -05:00

592 lines
39 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dscript.models &mdash; D-SCRIPT v1.0-beta documentation</title>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="prev" title="dscript.commands" href="dscript.commands.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html" class="icon icon-home"> D-SCRIPT
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../usage.html">Usage</a></li>
<li class="toctree-l1"><a class="reference internal" href="../data.html">Data</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">API</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="dscript.commands.html">dscript.commands</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">dscript.models</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#module-dscript.models.embedding">dscript.models.embedding</a></li>
<li class="toctree-l3"><a class="reference internal" href="#module-dscript.models.contact">dscript.models.contact</a></li>
<li class="toctree-l3"><a class="reference internal" href="#module-dscript.models.interaction">dscript.models.interaction</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="index.html#module-dscript.alphabets">dscript.alphabets</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#module-dscript.fasta">dscript.fasta</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#module-dscript.language_model">dscript.language_model</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#module-dscript.pretrained">dscript.pretrained</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html#module-dscript.utils">dscript.utils</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">D-SCRIPT</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
<li><a href="index.html">API</a> &raquo;</li>
<li>dscript.models</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/api/dscript.models.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="dscript-models">
<h1>dscript.models<a class="headerlink" href="#dscript-models" title="Permalink to this headline"></a></h1>
<div class="section" id="module-dscript.models.embedding">
<span id="dscript-models-embedding"></span><h2>dscript.models.embedding<a class="headerlink" href="#module-dscript.models.embedding" title="Permalink to this headline"></a></h2>
<p>Embedding model classes.</p>
<dl class="py class">
<dt id="dscript.models.embedding.FullyConnectedEmbed">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">dscript.models.embedding.</span></code><code class="sig-name descname"><span class="pre">FullyConnectedEmbed</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nin</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nout</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dropout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">activation</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">ReLU()</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/embedding.html#FullyConnectedEmbed"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.embedding.FullyConnectedEmbed" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.nn.modules.module.Module</span></code></p>
<p>Protein Projection Module. Takes embedding from language model and outputs low-dimensional interaction aware projection.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>nin</strong> (<em>int</em>) Size of language model output</p></li>
<li><p><strong>nout</strong> (<em>int</em>) Dimension of projection</p></li>
<li><p><strong>dropout</strong> (<em>float</em>) Proportion of weights to drop out [default: 0.5]</p></li>
<li><p><strong>activation</strong> (<em>torch.nn.Module</em>) Activation for linear projection model</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt id="dscript.models.embedding.FullyConnectedEmbed.forward">
<code class="sig-name descname"><span class="pre">forward</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/embedding.html#FullyConnectedEmbed.forward"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.embedding.FullyConnectedEmbed.forward" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>x</strong> (<em>torch.Tensor</em>) Input language model embedding <span class="math notranslate nohighlight">\((b \times N \times d_0)\)</span></p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Low dimensional projection of embedding</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>torch.Tensor</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt id="dscript.models.embedding.IdentityEmbed">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">dscript.models.embedding.</span></code><code class="sig-name descname"><span class="pre">IdentityEmbed</span></code><a class="reference internal" href="../_modules/dscript/models/embedding.html#IdentityEmbed"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.embedding.IdentityEmbed" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.nn.modules.module.Module</span></code></p>
<p>Does not reduce the dimension of the language model embeddings, just passes them through to the contact model.</p>
<dl class="py method">
<dt id="dscript.models.embedding.IdentityEmbed.forward">
<code class="sig-name descname"><span class="pre">forward</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/embedding.html#IdentityEmbed.forward"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.embedding.IdentityEmbed.forward" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>x</strong> (<em>torch.Tensor</em>) Input language model embedding <span class="math notranslate nohighlight">\((b \times N \times d_0)\)</span></p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Same embedding</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>torch.Tensor</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt id="dscript.models.embedding.SkipLSTM">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">dscript.models.embedding.</span></code><code class="sig-name descname"><span class="pre">SkipLSTM</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nin</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">21</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hidden_dim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1024</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">num_layers</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dropout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bidirectional</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/embedding.html#SkipLSTM"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.embedding.SkipLSTM" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.nn.modules.module.Module</span></code></p>
<p>Language model from <a class="reference external" href="https://github.com/tbepler/protein-sequence-embedding-iclr2019">Bepler &amp; Berger</a>.</p>
<p>Loaded with pre-trained weights in embedding function.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>nin</strong> (<em>int</em>) Input dimension of amino acid one-hot [default: 21]</p></li>
<li><p><strong>nout</strong> (<em>int</em>) Output dimension of final layer [default: 100]</p></li>
<li><p><strong>hidden_dim</strong> (<em>int</em>) Size of hidden dimension [default: 1024]</p></li>
<li><p><strong>num_layers</strong> (<em>int</em>) Number of stacked LSTM models [default: 3]</p></li>
<li><p><strong>dropout</strong> (<em>float</em>) Proportion of weights to drop out [default: 0]</p></li>
<li><p><strong>bidirectional</strong> (<em>bool</em>) Whether to use biLSTM vs. LSTM</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt id="dscript.models.embedding.SkipLSTM.to_one_hot">
<code class="sig-name descname"><span class="pre">to_one_hot</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/embedding.html#SkipLSTM.to_one_hot"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.embedding.SkipLSTM.to_one_hot" title="Permalink to this definition"></a></dt>
<dd><p>Transform numeric encoded amino acid vector to one-hot encoded vector</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>x</strong> (<em>torch.Tensor</em>) Input numeric amino acid encoding <span class="math notranslate nohighlight">\((N)\)</span></p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>One-hot encoding vector <span class="math notranslate nohighlight">\((N \times n_{in})\)</span></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>torch.Tensor</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="dscript.models.embedding.SkipLSTM.transform">
<code class="sig-name descname"><span class="pre">transform</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/embedding.html#SkipLSTM.transform"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.embedding.SkipLSTM.transform" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>x</strong> (<em>torch.Tensor</em>) Input numeric amino acid encoding <span class="math notranslate nohighlight">\((N)\)</span></p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Concatenation of all hidden layers <span class="math notranslate nohighlight">\((N \times (n_{in} + 2 \times \text{num_layers} \times \text{hidden_dim}))\)</span></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>torch.Tensor</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="module-dscript.models.contact">
<span id="dscript-models-contact"></span><h2>dscript.models.contact<a class="headerlink" href="#module-dscript.models.contact" title="Permalink to this headline"></a></h2>
<p>Contact model classes.</p>
<dl class="py class">
<dt id="dscript.models.contact.ContactCNN">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">dscript.models.contact.</span></code><code class="sig-name descname"><span class="pre">ContactCNN</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">embed_dim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hidden_dim</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">50</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">width</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">7</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">activation</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">Sigmoid()</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/contact.html#ContactCNN"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.contact.ContactCNN" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.nn.modules.module.Module</span></code></p>
<p>Residue Contact Prediction Module. Takes embeddings from Projection module and produces contact map, output of Contact module.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>embed_dim</strong> (<em>int</em>) <p>Output dimension of <a class="reference external" href="#module-dscript.models.embedding">dscript.models.embedding</a> model <span class="math notranslate nohighlight">\(d\)</span> [default: 100]</p>
</p></li>
<li><p><strong>hidden_dim</strong> (<em>int</em>) Hidden dimension <span class="math notranslate nohighlight">\(h\)</span> [default: 50]</p></li>
<li><p><strong>width</strong> (<em>int</em>) Width of convolutional filter <span class="math notranslate nohighlight">\(2w+1\)</span> [default: 7]</p></li>
<li><p><strong>activation</strong> (<em>torch.nn.Module</em>) Activation function for final contact map [default: torch.nn.Sigmoid()]</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt id="dscript.models.contact.ContactCNN.broadcast">
<code class="sig-name descname"><span class="pre">broadcast</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">z0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">z1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/contact.html#ContactCNN.broadcast"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.contact.ContactCNN.broadcast" title="Permalink to this definition"></a></dt>
<dd><p>Calls <a class="reference external" href="#module-dscript.models.contact.FullyConnected">dscript.models.contact.FullyConnected</a>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>z0</strong> (<em>torch.Tensor</em>) Projection module embedding <span class="math notranslate nohighlight">\((b \times N \times d)\)</span></p></li>
<li><p><strong>z1</strong> (<em>torch.Tensor</em>) Projection module embedding <span class="math notranslate nohighlight">\((b \times M \times d)\)</span></p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Predicted contact broadcast tensor <span class="math notranslate nohighlight">\((b \times N \times M \times h)\)</span></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>torch.Tensor</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="dscript.models.contact.ContactCNN.forward">
<code class="sig-name descname"><span class="pre">forward</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">z0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">z1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/contact.html#ContactCNN.forward"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.contact.ContactCNN.forward" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>z0</strong> (<em>torch.Tensor</em>) Projection module embedding <span class="math notranslate nohighlight">\((b \times N \times d)\)</span></p></li>
<li><p><strong>z1</strong> (<em>torch.Tensor</em>) Projection module embedding <span class="math notranslate nohighlight">\((b \times M \times d)\)</span></p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Predicted contact map <span class="math notranslate nohighlight">\((b \times N \times M)\)</span></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>torch.Tensor</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="dscript.models.contact.ContactCNN.predict">
<code class="sig-name descname"><span class="pre">predict</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">B</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/contact.html#ContactCNN.predict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.contact.ContactCNN.predict" title="Permalink to this definition"></a></dt>
<dd><p>Predict contact map from broadcast tensor.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>B</strong> (<em>torch.Tensor</em>) Predicted contact broadcast <span class="math notranslate nohighlight">\((b \times N \times M \times h)\)</span></p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Predicted contact map <span class="math notranslate nohighlight">\((b \times N \times M)\)</span></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>torch.Tensor</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt id="dscript.models.contact.FullyConnected">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">dscript.models.contact.</span></code><code class="sig-name descname"><span class="pre">FullyConnected</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">embed_dim</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">hidden_dim</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">activation</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">ReLU()</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/contact.html#FullyConnected"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.contact.FullyConnected" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.nn.modules.module.Module</span></code></p>
<p>Performs part 1 of Contact Prediction Module. Takes embeddings from Projection module and produces broadcast tensor.</p>
<p>Input embeddings of dimension <span class="math notranslate nohighlight">\(d\)</span> are combined into a <span class="math notranslate nohighlight">\(2d\)</span> length MLP input <span class="math notranslate nohighlight">\(z_{cat}\)</span>, where <span class="math notranslate nohighlight">\(z_{cat} = [z_0 \ominus z_1 | z_0 \odot z_1]\)</span></p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>embed_dim</strong> (<em>int</em>) <p>Output dimension of <a class="reference external" href="#module-dscript.models.embedding">dscript.models.embedding</a> model <span class="math notranslate nohighlight">\(d\)</span> [default: 100]</p>
</p></li>
<li><p><strong>hidden_dim</strong> (<em>int</em>) Hidden dimension <span class="math notranslate nohighlight">\(h\)</span> [default: 50]</p></li>
<li><p><strong>activation</strong> (<em>torch.nn.Module</em>) Activation function for broadcast tensor [default: torch.nn.ReLU()]</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt id="dscript.models.contact.FullyConnected.forward">
<code class="sig-name descname"><span class="pre">forward</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">z0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">z1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/contact.html#FullyConnected.forward"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.contact.FullyConnected.forward" title="Permalink to this definition"></a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>z0</strong> (<em>torch.Tensor</em>) Projection module embedding <span class="math notranslate nohighlight">\((b \times N \times d)\)</span></p></li>
<li><p><strong>z1</strong> (<em>torch.Tensor</em>) Projection module embedding <span class="math notranslate nohighlight">\((b \times M \times d)\)</span></p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Predicted broadcast tensor <span class="math notranslate nohighlight">\((b \times N \times M \times h)\)</span></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>torch.Tensor</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="module-dscript.models.interaction">
<span id="dscript-models-interaction"></span><h2>dscript.models.interaction<a class="headerlink" href="#module-dscript.models.interaction" title="Permalink to this headline"></a></h2>
<p>Interaction model classes.</p>
<dl class="py class">
<dt id="dscript.models.interaction.LogisticActivation">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">dscript.models.interaction.</span></code><code class="sig-name descname"><span class="pre">LogisticActivation</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x0</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">k</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">train</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/interaction.html#LogisticActivation"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.interaction.LogisticActivation" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.nn.modules.module.Module</span></code></p>
<p>Implementation of Generalized Sigmoid
Applies the element-wise function:</p>
<p><span class="math notranslate nohighlight">\(\sigma(x) = \frac{1}{1 + \exp(-k(x-x_0))}\)</span></p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x0</strong> (<em>float</em>) The value of the sigmoid midpoint</p></li>
<li><p><strong>k</strong> (<em>float</em>) The slope of the sigmoid - trainable - <span class="math notranslate nohighlight">\(k \geq 0\)</span></p></li>
<li><p><strong>train</strong> (<em>bool</em>) Whether <span class="math notranslate nohighlight">\(k\)</span> is a trainable parameter</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt id="dscript.models.interaction.LogisticActivation.forward">
<code class="sig-name descname"><span class="pre">forward</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/interaction.html#LogisticActivation.forward"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.interaction.LogisticActivation.forward" title="Permalink to this definition"></a></dt>
<dd><p>Applies the function to the input elementwise</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>x</strong> (<em>torch.Tensor</em>) <span class="math notranslate nohighlight">\((N \times *)\)</span> where <span class="math notranslate nohighlight">\(*\)</span> means, any number of additional dimensions</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><span class="math notranslate nohighlight">\((N \times *)\)</span>, same shape as the input</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>torch.Tensor</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt id="dscript.models.interaction.ModelInteraction">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">dscript.models.interaction.</span></code><code class="sig-name descname"><span class="pre">ModelInteraction</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">embedding</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">contact</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pool_size</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">9</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">theta_init</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lambda_init</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">gamma_init</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_W</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/interaction.html#ModelInteraction"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.interaction.ModelInteraction" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.nn.modules.module.Module</span></code></p>
<p>Main D-SCRIPT model. Contains an embedding and contact model and offers access to those models. Computes pooling operations on contact map to generate interaction probability.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>embedding</strong> (<a class="reference internal" href="#dscript.models.embedding.FullyConnectedEmbed" title="dscript.models.embedding.FullyConnectedEmbed"><em>dscript.models.embedding.FullyConnectedEmbed</em></a>) Embedding model</p></li>
<li><p><strong>contact</strong> (<a class="reference internal" href="#dscript.models.contact.ContactCNN" title="dscript.models.contact.ContactCNN"><em>dscript.models.contact.ContactCNN</em></a>) Contact model</p></li>
<li><p><strong>use_cuda</strong> (<em>bool</em>) Whether the model should be run on GPU</p></li>
<li><p><strong>pool_size</strong> (<em>bool</em>) width of max-pool [default 9]</p></li>
<li><p><strong>theta_init</strong> (<em>float</em>) initialization value of <span class="math notranslate nohighlight">\(\theta\)</span> for weight matrix [default: 1]</p></li>
<li><p><strong>lambda_init</strong> (<em>float</em>) initialization value of <span class="math notranslate nohighlight">\(\lambda\)</span> for weight matrix [default: 0]</p></li>
<li><p><strong>gamma_init</strong> (<em>float</em>) initialization value of <span class="math notranslate nohighlight">\(\gamma\)</span> for global pooling [default: 0]</p></li>
<li><p><strong>use_W</strong> (<em>bool</em>) whether to use the weighting matrix [default: True]</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt id="dscript.models.interaction.ModelInteraction.cpred">
<code class="sig-name descname"><span class="pre">cpred</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">z0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">z1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/interaction.html#ModelInteraction.cpred"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.interaction.ModelInteraction.cpred" title="Permalink to this definition"></a></dt>
<dd><p>Project down input language model embeddings into low dimension using projection module</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>z0</strong> (<em>torch.Tensor</em>) Language model embedding <span class="math notranslate nohighlight">\((b \times N \times d_0)\)</span></p></li>
<li><p><strong>z1</strong> (<em>torch.Tensor</em>) Language model embedding <span class="math notranslate nohighlight">\((b \times N \times d_0)\)</span></p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Predicted contact map <span class="math notranslate nohighlight">\((b \times N \times M)\)</span></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>torch.Tensor</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="dscript.models.interaction.ModelInteraction.embed">
<code class="sig-name descname"><span class="pre">embed</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">z</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/interaction.html#ModelInteraction.embed"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.interaction.ModelInteraction.embed" title="Permalink to this definition"></a></dt>
<dd><p>Project down input language model embeddings into low dimension using projection module</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>z</strong> (<em>torch.Tensor</em>) Language model embedding <span class="math notranslate nohighlight">\((b \times N \times d_0)\)</span></p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>D-SCRIPT projection <span class="math notranslate nohighlight">\((b \times N \times d)\)</span></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>torch.Tensor</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="dscript.models.interaction.ModelInteraction.map_predict">
<code class="sig-name descname"><span class="pre">map_predict</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">z0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">z1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/interaction.html#ModelInteraction.map_predict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.interaction.ModelInteraction.map_predict" title="Permalink to this definition"></a></dt>
<dd><p>Project down input language model embeddings into low dimension using projection module</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>z0</strong> (<em>torch.Tensor</em>) Language model embedding <span class="math notranslate nohighlight">\((b \times N \times d_0)\)</span></p></li>
<li><p><strong>z1</strong> (<em>torch.Tensor</em>) Language model embedding <span class="math notranslate nohighlight">\((b \times N \times d_0)\)</span></p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Predicted contact map, predicted probability of interaction <span class="math notranslate nohighlight">\((b \times N \times d_0), (1)\)</span></p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>torch.Tensor, torch.Tensor</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="dscript.models.interaction.ModelInteraction.predict">
<code class="sig-name descname"><span class="pre">predict</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">z0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">z1</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/dscript/models/interaction.html#ModelInteraction.predict"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#dscript.models.interaction.ModelInteraction.predict" title="Permalink to this definition"></a></dt>
<dd><p>Project down input language model embeddings into low dimension using projection module</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>z0</strong> (<em>torch.Tensor</em>) Language model embedding <span class="math notranslate nohighlight">\((b \times N \times d_0)\)</span></p></li>
<li><p><strong>z1</strong> (<em>torch.Tensor</em>) Language model embedding <span class="math notranslate nohighlight">\((b \times N \times d_0)\)</span></p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Predicted probability of interaction</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>torch.Tensor, torch.Tensor</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="dscript.commands.html" class="btn btn-neutral float-left" title="dscript.commands" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&#169; Copyright 2020, Samuel Sledzieski, Rohit Singh.
</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>