File size: 40,458 Bytes
8896a5f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 |
<!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 — 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> »</li>
<li><a href="index.html">API</a> »</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 & 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>
© 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> |