Skip to content

Commit

Permalink
modified: docs/dsm_api.html
Browse files Browse the repository at this point in the history
	modified:   docs/dsm_torch.html
	modified:   docs/index.html
  • Loading branch information
chiragnagpal committed Feb 3, 2021
1 parent 1aaf17a commit 6dc87f0
Show file tree
Hide file tree
Showing 3 changed files with 248 additions and 4 deletions.
153 changes: 153 additions & 0 deletions docs/dsm_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,149 @@ <h2 id="returns">Returns</h2>
</dd>
</dl>
</dd>
<dt id="dsm.dsm_api.DeepCNNRNNSurvivalMachines"><code class="flex name class">
<span>class <span class="ident">DeepCNNRNNSurvivalMachines</span></span>
<span>(</span><span>k=3, layers=None, hidden=None, distribution='Weibull', temp=1000.0, discount=1.0, typ='LSTM')</span>
</code></dt>
<dd>
<div class="desc"><p>The Deep CNN-RNN Survival Machines model to handle data with
moving image streams.</p></div>
<h3>Methods</h3>
<dl>
<dt id="dsm.dsm_api.DeepCNNRNNSurvivalMachines.fit"><code class="name flex">
<span>def <span class="ident">fit</span></span>(<span>self, x, t, e, vsize=0.15, iters=1, learning_rate=0.001, batch_size=100, elbo=True, optimizer='Adam', random_state=100)</span>
</code></dt>
<dd>
<p class="inheritance">
<em>Inherited from:</em>
<code><a title="dsm.dsm_api.DeepRecurrentSurvivalMachines" href="#dsm.dsm_api.DeepRecurrentSurvivalMachines">DeepRecurrentSurvivalMachines</a></code>.<code><a title="dsm.dsm_api.DeepRecurrentSurvivalMachines.fit" href="#dsm.dsm_api.DeepRecurrentSurvivalMachines.fit">fit</a></code>
</p>
<div class="desc"><p>This method is used to train an instance of the DSM model.</p>
<h2 id="parameters">Parameters</h2>
<dl>
<dt><strong><code>x</code></strong> :&ensp;<code>np.ndarray</code></dt>
<dd>A numpy array of the input features, <span><span class="MathJax_Preview"> x </span><script type="math/tex"> x </script></span>.</dd>
<dt><strong><code>t</code></strong> :&ensp;<code>np.ndarray</code></dt>
<dd>A numpy array of the event/censoring times, <span><span class="MathJax_Preview"> t </span><script type="math/tex"> t </script></span>.</dd>
<dt><strong><code>e</code></strong> :&ensp;<code>np.ndarray</code></dt>
<dd>A numpy array of the event/censoring indicators, <span><span class="MathJax_Preview"> \delta </span><script type="math/tex"> \delta </script></span>.
<span><span class="MathJax_Preview"> \delta = 1 </span><script type="math/tex"> \delta = 1 </script></span> means the event took place.</dd>
<dt><strong><code>vsize</code></strong> :&ensp;<code>float</code></dt>
<dd>Amount of data to set aside as the validation set.</dd>
<dt><strong><code>iters</code></strong> :&ensp;<code>int</code></dt>
<dd>The maximum number of training iterations on the training dataset.</dd>
<dt><strong><code>learning_rate</code></strong> :&ensp;<code>float</code></dt>
<dd>The learning rate for the <code>Adam</code> optimizer.</dd>
<dt><strong><code>batch_size</code></strong> :&ensp;<code>int</code></dt>
<dd>learning is performed on mini-batches of input data. this parameter
specifies the size of each mini-batch.</dd>
<dt><strong><code>elbo</code></strong> :&ensp;<code>bool</code></dt>
<dd>Whether to use the Evidence Lower Bound for optimization.
Default is True.</dd>
<dt><strong><code>optimizer</code></strong> :&ensp;<code>str</code></dt>
<dd>The choice of the gradient based optimization method. One of
'Adam', 'RMSProp' or 'SGD'.</dd>
<dt><strong><code>random_state</code></strong> :&ensp;<code>float</code></dt>
<dd>random seed that determines how the validation set is chosen.</dd>
</dl></div>
</dd>
<dt id="dsm.dsm_api.DeepCNNRNNSurvivalMachines.compute_nll"><code class="name flex">
<span>def <span class="ident">compute_nll</span></span>(<span>self, x, t, e)</span>
</code></dt>
<dd>
<p class="inheritance">
<em>Inherited from:</em>
<code><a title="dsm.dsm_api.DeepRecurrentSurvivalMachines" href="#dsm.dsm_api.DeepRecurrentSurvivalMachines">DeepRecurrentSurvivalMachines</a></code>.<code><a title="dsm.dsm_api.DeepRecurrentSurvivalMachines.compute_nll" href="#dsm.dsm_api.DeepRecurrentSurvivalMachines.compute_nll">compute_nll</a></code>
</p>
<div class="desc"><p>This function computes the negative log likelihood of the given data.
In case of competing risks, the negative log likelihoods are summed over
the different events' type.</p>
<h2 id="parameters">Parameters</h2>
<dl>
<dt><strong><code>x</code></strong> :&ensp;<code>np.ndarray</code></dt>
<dd>A numpy array of the input features, <span><span class="MathJax_Preview"> x </span><script type="math/tex"> x </script></span>.</dd>
<dt><strong><code>t</code></strong> :&ensp;<code>np.ndarray</code></dt>
<dd>A numpy array of the event/censoring times, <span><span class="MathJax_Preview"> t </span><script type="math/tex"> t </script></span>.</dd>
<dt><strong><code>e</code></strong> :&ensp;<code>np.ndarray</code></dt>
<dd>A numpy array of the event/censoring indicators, <span><span class="MathJax_Preview"> \delta </span><script type="math/tex"> \delta </script></span>.
<span><span class="MathJax_Preview"> \delta = r </span><script type="math/tex"> \delta = r </script></span> means the event r took place.</dd>
</dl>
<h2 id="returns">Returns</h2>
<dl>
<dt><code>float</code></dt>
<dd>Negative log likelihood.</dd>
</dl></div>
</dd>
<dt id="dsm.dsm_api.DeepCNNRNNSurvivalMachines.predict_mean"><code class="name flex">
<span>def <span class="ident">predict_mean</span></span>(<span>self, x, risk=1)</span>
</code></dt>
<dd>
<p class="inheritance">
<em>Inherited from:</em>
<code><a title="dsm.dsm_api.DeepRecurrentSurvivalMachines" href="#dsm.dsm_api.DeepRecurrentSurvivalMachines">DeepRecurrentSurvivalMachines</a></code>.<code><a title="dsm.dsm_api.DeepRecurrentSurvivalMachines.predict_mean" href="#dsm.dsm_api.DeepRecurrentSurvivalMachines.predict_mean">predict_mean</a></code>
</p>
<div class="desc"><p>Returns the mean Time-to-Event <span><span class="MathJax_Preview"> t </span><script type="math/tex"> t </script></span></p>
<h2 id="parameters">Parameters</h2>
<dl>
<dt><strong><code>x</code></strong> :&ensp;<code>np.ndarray</code></dt>
<dd>A numpy array of the input features, <span><span class="MathJax_Preview"> x </span><script type="math/tex"> x </script></span>.</dd>
</dl>
<h2 id="returns">Returns</h2>
<dl>
<dt><code>np.array</code></dt>
<dd>numpy array of the mean time to event.</dd>
</dl></div>
</dd>
<dt id="dsm.dsm_api.DeepCNNRNNSurvivalMachines.predict_risk"><code class="name flex">
<span>def <span class="ident">predict_risk</span></span>(<span>self, x, t, risk=1)</span>
</code></dt>
<dd>
<p class="inheritance">
<em>Inherited from:</em>
<code><a title="dsm.dsm_api.DeepRecurrentSurvivalMachines" href="#dsm.dsm_api.DeepRecurrentSurvivalMachines">DeepRecurrentSurvivalMachines</a></code>.<code><a title="dsm.dsm_api.DeepRecurrentSurvivalMachines.predict_risk" href="#dsm.dsm_api.DeepRecurrentSurvivalMachines.predict_risk">predict_risk</a></code>
</p>
<div class="desc"><p>Returns the estimated risk of an event occuring before time <span><span class="MathJax_Preview"> t </span><script type="math/tex"> t </script></span>
<span><span class="MathJax_Preview"> \widehat{\mathbb{P}}(T\leq t|X) </span><script type="math/tex"> \widehat{\mathbb{P}}(T\leq t|X) </script></span> for some input data <span><span class="MathJax_Preview"> x </span><script type="math/tex"> x </script></span>.</p>
<h2 id="parameters">Parameters</h2>
<dl>
<dt><strong><code>x</code></strong> :&ensp;<code>np.ndarray</code></dt>
<dd>A numpy array of the input features, <span><span class="MathJax_Preview"> x </span><script type="math/tex"> x </script></span>.</dd>
<dt><strong><code>t</code></strong> :&ensp;<code>list</code> or <code>float</code></dt>
<dd>a list or float of the times at which survival probability is
to be computed</dd>
</dl>
<h2 id="returns">Returns</h2>
<dl>
<dt><code>np.array</code></dt>
<dd>numpy array of the risks at each time in t.</dd>
</dl></div>
</dd>
<dt id="dsm.dsm_api.DeepCNNRNNSurvivalMachines.predict_survival"><code class="name flex">
<span>def <span class="ident">predict_survival</span></span>(<span>self, x, t, risk=1)</span>
</code></dt>
<dd>
<p class="inheritance">
<em>Inherited from:</em>
<code><a title="dsm.dsm_api.DeepRecurrentSurvivalMachines" href="#dsm.dsm_api.DeepRecurrentSurvivalMachines">DeepRecurrentSurvivalMachines</a></code>.<code><a title="dsm.dsm_api.DeepRecurrentSurvivalMachines.predict_survival" href="#dsm.dsm_api.DeepRecurrentSurvivalMachines.predict_survival">predict_survival</a></code>
</p>
<div class="desc"><p>Returns the estimated survival probability at time <span><span class="MathJax_Preview"> t </span><script type="math/tex"> t </script></span>,
<span><span class="MathJax_Preview"> \widehat{\mathbb{P}}(T &gt; t|X) </span><script type="math/tex"> \widehat{\mathbb{P}}(T > t|X) </script></span> for some input data <span><span class="MathJax_Preview"> x </span><script type="math/tex"> x </script></span>.</p>
<h2 id="parameters">Parameters</h2>
<dl>
<dt><strong><code>x</code></strong> :&ensp;<code>np.ndarray</code></dt>
<dd>A numpy array of the input features, <span><span class="MathJax_Preview"> x </span><script type="math/tex"> x </script></span>.</dd>
<dt><strong><code>t</code></strong> :&ensp;<code>list</code> or <code>float</code></dt>
<dd>a list or float of the times at which survival probability is
to be computed</dd>
</dl>
<h2 id="returns">Returns</h2>
<dl>
<dt><code>np.array</code></dt>
<dd>numpy array of the survival probabilites at each time in t.</dd>
</dl></div>
</dd>
</dl>
</dd>
</dl>
</section>
</article>
Expand Down Expand Up @@ -548,6 +691,16 @@ <h4><code><a title="dsm.dsm_api.DeepConvolutionalSurvivalMachines" href="#dsm.ds
<li><code><a title="dsm.dsm_api.DeepConvolutionalSurvivalMachines.predict_survival" href="#dsm.dsm_api.DeepConvolutionalSurvivalMachines.predict_survival">predict_survival</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="dsm.dsm_api.DeepCNNRNNSurvivalMachines" href="#dsm.dsm_api.DeepCNNRNNSurvivalMachines">DeepCNNRNNSurvivalMachines</a></code></h4>
<ul class="">
<li><code><a title="dsm.dsm_api.DeepCNNRNNSurvivalMachines.fit" href="#dsm.dsm_api.DeepCNNRNNSurvivalMachines.fit">fit</a></code></li>
<li><code><a title="dsm.dsm_api.DeepCNNRNNSurvivalMachines.compute_nll" href="#dsm.dsm_api.DeepCNNRNNSurvivalMachines.compute_nll">compute_nll</a></code></li>
<li><code><a title="dsm.dsm_api.DeepCNNRNNSurvivalMachines.predict_mean" href="#dsm.dsm_api.DeepCNNRNNSurvivalMachines.predict_mean">predict_mean</a></code></li>
<li><code><a title="dsm.dsm_api.DeepCNNRNNSurvivalMachines.predict_risk" href="#dsm.dsm_api.DeepCNNRNNSurvivalMachines.predict_risk">predict_risk</a></code></li>
<li><code><a title="dsm.dsm_api.DeepCNNRNNSurvivalMachines.predict_survival" href="#dsm.dsm_api.DeepCNNRNNSurvivalMachines.predict_survival">predict_survival</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
Expand Down
97 changes: 93 additions & 4 deletions docs/dsm_torch.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h2 id="returns">Returns</h2>
<p>an MLP with torch.nn.Module with the specfied structure.</p></div>
</dd>
<dt id="dsm.dsm_torch.create_conv_representation"><code class="name flex">
<span>def <span class="ident">create_conv_representation</span></span>(<span>inputdim, hidden, typ='ConvNet')</span>
<span>def <span class="ident">create_conv_representation</span></span>(<span>inputdim, hidden, typ='ConvNet', add_linear=True)</span>
</code></dt>
<dd>
<div class="desc"><p>Helper function to generate the representation function for DSM.</p>
Expand All @@ -80,8 +80,8 @@ <h2 id="returns">Returns</h2>
</div>
<h2 id="parameters">Parameters</h2>
<dl>
<dt><strong><code>inputdim</code></strong> :&ensp;<code>int</code></dt>
<dd>Dimensionality of the input features.</dd>
<dt><strong><code>inputdim</code></strong> :&ensp;<code>tuple</code></dt>
<dd>Dimensionality of the input image.</dd>
<dt><strong><code>hidden</code></strong> :&ensp;<code>int</code></dt>
<dd>The number of neurons in each hidden layer.</dd>
<dt><strong><code>typ</code></strong> :&ensp;<code>str</code></dt>
Expand Down Expand Up @@ -245,7 +245,7 @@ <h2 id="args">Args</h2>
</div>
<h2 id="parameters">Parameters</h2>
<dl>
<dt><strong><code>inputdim</code></strong> :&ensp;<code>int</code></dt>
<dt><strong><code>inputdim</code></strong> :&ensp;<code>tuple</code></dt>
<dd>Dimensionality of the input features. A tuple (height, width).</dd>
<dt><strong><code>k</code></strong> :&ensp;<code>int</code></dt>
<dd>The number of underlying parametric distributions.</dd>
Expand Down Expand Up @@ -284,6 +284,10 @@ <h3>Methods</h3>
<span>def <span class="ident">forward</span></span>(<span>self, x, risk='1') ‑> Callable[..., Any]</span>
</code></dt>
<dd>
<p class="inheritance">
<em>Inherited from:</em>
<code><a title="dsm.dsm_torch.DeepSurvivalMachinesTorch" href="#dsm.dsm_torch.DeepSurvivalMachinesTorch">DeepSurvivalMachinesTorch</a></code>.<code><a title="dsm.dsm_torch.DeepSurvivalMachinesTorch.forward" href="#dsm.dsm_torch.DeepSurvivalMachinesTorch.forward">forward</a></code>
</p>
<div class="desc"><p>The forward function that is called when data is passed through DSM.</p>
<h2 id="args">Args</h2>
<p>x:
Expand All @@ -297,6 +301,82 @@ <h2 id="args">Args</h2>
</dd>
</dl>
</dd>
<dt id="dsm.dsm_torch.DeepCNNRNNSurvivalMachinesTorch"><code class="flex name class">
<span>class <span class="ident">DeepCNNRNNSurvivalMachinesTorch</span></span>
<span>(</span><span>inputdim, k, typ='LSTM', layers=1, hidden=None, dist='Weibull', temp=1000.0, discount=1.0, optimizer='Adam', risks=1)</span>
</code></dt>
<dd>
<div class="desc"><p>A Torch implementation of Deep CNN Recurrent Survival Machines model.</p>
<p>This is an implementation of Deep Recurrent Survival Machines model
in torch. It inherits from <code><a title="dsm.dsm_torch.DeepSurvivalMachinesTorch" href="#dsm.dsm_torch.DeepSurvivalMachinesTorch">DeepSurvivalMachinesTorch</a></code> and replaces the
input representation learning MLP with an LSTM or RNN, the parameters of the
underlying distributions and the forward function which is called whenever
data is passed to the module. Each of the parameters are nn.Parameters and
torch automatically keeps track and computes gradients for them.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Not designed to be used directly.
Please use the API inferface <code><a title="dsm.dsm_api.DeepCNNRNNSurvivalMachines" href="dsm_api.html#dsm.dsm_api.DeepCNNRNNSurvivalMachines">DeepCNNRNNSurvivalMachines</a></code>!!</p>
</div>
<h2 id="parameters">Parameters</h2>
<dl>
<dt><strong><code>inputdim</code></strong> :&ensp;<code>tuple</code></dt>
<dd>Dimensionality of the input features. (height, width)</dd>
<dt><strong><code>k</code></strong> :&ensp;<code>int</code></dt>
<dd>The number of underlying parametric distributions.</dd>
<dt><strong><code>layers</code></strong> :&ensp;<code>int</code></dt>
<dd>The number of hidden layers in the LSTM or RNN cell.</dd>
<dt><strong><code>hidden</code></strong> :&ensp;<code>int</code></dt>
<dd>The number of neurons in each hidden layer.</dd>
<dt><strong><code>init</code></strong> :&ensp;<code>tuple</code></dt>
<dd>A tuple for initialization of the parameters for the underlying
distributions. (shape, scale).</dd>
<dt><strong><code>dist</code></strong> :&ensp;<code>str</code></dt>
<dd>Choice of the underlying survival distributions.
One of 'Weibull', 'LogNormal'.
Default is 'Weibull'.</dd>
<dt><strong><code>temp</code></strong> :&ensp;<code>float</code></dt>
<dd>The logits for the gate are rescaled with this value.
Default is 1000.</dd>
<dt><strong><code>discount</code></strong> :&ensp;<code>float</code></dt>
<dd>a float in [0,1] that determines how to discount the tail bias
from the uncensored instances.
Default is 1.</dd>
</dl>
<p>Initializes internal Module state, shared by both nn.Module and ScriptModule.</p></div>
<h3>Class variables</h3>
<dl>
<dt id="dsm.dsm_torch.DeepCNNRNNSurvivalMachinesTorch.dump_patches"><code class="name">var <span class="ident">dump_patches</span> : bool</code></dt>
<dd>
<div class="desc"></div>
</dd>
<dt id="dsm.dsm_torch.DeepCNNRNNSurvivalMachinesTorch.training"><code class="name">var <span class="ident">training</span> : bool</code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
<h3>Methods</h3>
<dl>
<dt id="dsm.dsm_torch.DeepCNNRNNSurvivalMachinesTorch.forward"><code class="name flex">
<span>def <span class="ident">forward</span></span>(<span>self, x, risk='1') ‑> Callable[..., Any]</span>
</code></dt>
<dd>
<div class="desc"><p>The forward function that is called when data is passed through DSM.</p>
<p>Note: As compared to DSM, the input data for DCRSM is a tensor. The forward
function involves unpacking the tensor in-order to directly use the
DSM loss functions.</p>
<h2 id="args">Args</h2>
<p>x:
a torch.tensor of the input features.</p></div>
</dd>
<dt id="dsm.dsm_torch.DeepCNNRNNSurvivalMachinesTorch.get_shape_scale"><code class="name flex">
<span>def <span class="ident">get_shape_scale</span></span>(<span>self, risk='1')</span>
</code></dt>
<dd>
<div class="desc"></div>
</dd>
</dl>
</dd>
</dl>
</section>
</article>
Expand Down Expand Up @@ -342,6 +422,15 @@ <h4><code><a title="dsm.dsm_torch.DeepConvolutionalSurvivalMachinesTorch" href="
<li><code><a title="dsm.dsm_torch.DeepConvolutionalSurvivalMachinesTorch.training" href="#dsm.dsm_torch.DeepConvolutionalSurvivalMachinesTorch.training">training</a></code></li>
</ul>
</li>
<li>
<h4><code><a title="dsm.dsm_torch.DeepCNNRNNSurvivalMachinesTorch" href="#dsm.dsm_torch.DeepCNNRNNSurvivalMachinesTorch">DeepCNNRNNSurvivalMachinesTorch</a></code></h4>
<ul class="">
<li><code><a title="dsm.dsm_torch.DeepCNNRNNSurvivalMachinesTorch.forward" href="#dsm.dsm_torch.DeepCNNRNNSurvivalMachinesTorch.forward">forward</a></code></li>
<li><code><a title="dsm.dsm_torch.DeepCNNRNNSurvivalMachinesTorch.get_shape_scale" href="#dsm.dsm_torch.DeepCNNRNNSurvivalMachinesTorch.get_shape_scale">get_shape_scale</a></code></li>
<li><code><a title="dsm.dsm_torch.DeepCNNRNNSurvivalMachinesTorch.dump_patches" href="#dsm.dsm_torch.DeepCNNRNNSurvivalMachinesTorch.dump_patches">dump_patches</a></code></li>
<li><code><a title="dsm.dsm_torch.DeepCNNRNNSurvivalMachinesTorch.training" href="#dsm.dsm_torch.DeepCNNRNNSurvivalMachinesTorch.training">training</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
Expand Down
2 changes: 2 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ <h1 class="title">Package <code>dsm</code></h1>
<section id="section-intro">
<p><a href="https://travis-ci.org/autonlab/DeepSurvivalMachines"><img alt="Build Status" src="https://travis-ci.org/autonlab/DeepSurvivalMachines.svg?branch=master"></a>
&nbsp;&nbsp;&nbsp;
<a href="https://codecov.io/gh/autonlab/DeepSurvivalMachines"><img alt="codecov" src="https://codecov.io/gh/autonlab/DeepSurvivalMachines/branch/master/graph/badge.svg?token=FU1HB5O92D"></a>
&nbsp;&nbsp;&nbsp;
<a href="https://opensource.org/licenses/MIT"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg"></a>
&nbsp;&nbsp;&nbsp;
<a href="https://github.com/autonlab/DeepSurvivalMachines"><img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/autonlab/DeepSurvivalMachines?style=social"></a></p>
Expand Down

0 comments on commit 6dc87f0

Please sign in to comment.