# Module auton_survival.models.dsm.dsm_torch

Torch model definitons for the Deep Survival Machines model

This includes definitons for the Torch Deep Survival Machines module. The main interface is the DeepSurvivalMachines class which inherits from torch.nn.Module.

Note: NOT DESIGNED TO BE CALLED DIRECTLY!!!

## Functions

 def create_representation(inputdim, layers, activation, bias=False) 

Helper function to generate the representation function for DSM.

Deep Survival Machines learns a representation (\ Phi(X) ) for the input data. This representation is parameterized using a Non Linear Multilayer Perceptron (torch.nn.Module). This is a helper function designed to instantiate the representation for Deep Survival Machines.

Warning

Not designed to be used directly.

## Parameters

inputdim : int
Dimensionality of the input features.
layers : list
A list consisting of the number of neurons in each hidden layer.
activation : str
Choice of activation function: One of 'ReLU6', 'ReLU' or 'SeLU'.

## Returns

an MLP with torch.nn.Module with the specfied structure.

 def create_conv_representation(inputdim, hidden, typ='ConvNet', add_linear=True) 

Helper function to generate the representation function for DSM.

Deep Survival Machines learns a representation (\ Phi(X) ) for the input data. This representation is parameterized using a Convolutional Neural Network (torch.nn.Module). This is a helper function designed to instantiate the representation for Deep Survival Machines.

Warning

Not designed to be used directly.

## Parameters

inputdim : tuple
Dimensionality of the input image.
hidden : int
The number of neurons in each hidden layer.
typ : str
Choice of convolutional neural network: One of 'ConvNet'

## Returns

an ConvNet with torch.nn.Module with the specfied structure.

## Classes

 class DeepSurvivalMachinesTorch (inputdim, k, layers=None, dist='Weibull', temp=1000.0, discount=1.0, optimizer='Adam', risks=1) 

A Torch implementation of Deep Survival Machines model.

This is an implementation of Deep Survival Machines model in torch. It inherits from the torch.nn.Module class and includes references to the representation learning MLP, the parameters of the underlying distributions and the forward function which is called whenver data is passed to the module. Each of the parameters are nn.Parameters and torch automatically keeps track and computes gradients for them.

Warning

Not designed to be used directly. Please use the API inferface dsm.DeepSurvivalMachines !!!

## Parameters

inputdim : int
Dimensionality of the input features.
k : int
The number of underlying parametric distributions.
layers : list
A list of integers consisting of the number of neurons in each hidden layer.
init : tuple
A tuple for initialization of the parameters for the underlying distributions. (shape, scale).
activation : str
Choice of activation function for the MLP representation. One of 'ReLU6', 'ReLU' or 'SeLU'. Default is 'ReLU6'.
dist : str
Choice of the underlying survival distributions. One of 'Weibull', 'LogNormal'. Default is 'Weibull'.
temp : float
The logits for the gate are rescaled with this value. Default is 1000.
discount : float
a float in [0,1] that determines how to discount the tail bias from the uncensored instances. Default is 1.

Initializes internal Module state, shared by both nn.Module and ScriptModule.

### Methods

 def forward(self, x, risk='1') ‑> Callable[..., Any] 

The forward function that is called when data is passed through DSM.

## Args

x: a torch.tensor of the input features.

 def get_shape_scale(self, risk='1') 
 class DeepRecurrentSurvivalMachinesTorch (inputdim, k, typ='LSTM', layers=1, hidden=None, dist='Weibull', temp=1000.0, discount=1.0, optimizer='Adam', risks=1) 

A Torch implementation of Deep Recurrent Survival Machines model.

This is an implementation of Deep Recurrent Survival Machines model in torch. It inherits from DeepSurvivalMachinesTorch 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.

Warning

Not designed to be used directly. Please use the API inferface dsm.DeepRecurrentSurvivalMachines!!

## Parameters

inputdim : int
Dimensionality of the input features.
k : int
The number of underlying parametric distributions.
layers : int
The number of hidden layers in the LSTM or RNN cell.
hidden : int
The number of neurons in each hidden layer.
init : tuple
A tuple for initialization of the parameters for the underlying distributions. (shape, scale).
dist : str
Choice of the underlying survival distributions. One of 'Weibull', 'LogNormal'. Default is 'Weibull'.
temp : float
The logits for the gate are rescaled with this value. Default is 1000.
discount : float
a float in [0,1] that determines how to discount the tail bias from the uncensored instances. Default is 1.

Initializes internal Module state, shared by both nn.Module and ScriptModule.

### Methods

 def forward(self, x, risk='1') ‑> Callable[..., Any] 

The forward function that is called when data is passed through DSM.

Note: As compared to DSM, the input data for DRSM is a tensor. The forward function involves unpacking the tensor in-order to directly use the DSM loss functions.

## Args

x: a torch.tensor of the input features.

 def get_shape_scale(self, risk='1') 
 class DeepConvolutionalSurvivalMachinesTorch (inputdim, k, embedding=None, hidden=None, dist='Weibull', temp=1000.0, discount=1.0, optimizer='Adam', risks=1) 

A Torch implementation of Deep Convolutional Survival Machines model.

This is an implementation of Deep Convolutional Survival Machines model in torch. It inherits from DeepSurvivalMachinesTorch and replaces the input representation learning MLP with an simple convnet, 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.

Warning

Not designed to be used directly. Please use the API inferface dsm.DeepConvolutionalSurvivalMachines!!

## Parameters

inputdim : tuple
Dimensionality of the input features. A tuple (height, width).
k : int
The number of underlying parametric distributions.
embedding : torch.nn.Module
A torch CNN to obtain the representation of the input data.
hidden : int
The number of neurons in each hidden layer.
dist : str
Choice of the underlying survival distributions. One of 'Weibull', 'LogNormal'. Default is 'Weibull'.
temp : float
The logits for the gate are rescaled with this value. Default is 1000.
discount : float
a float in [0,1] that determines how to discount the tail bias from the uncensored instances. Default is 1.

Initializes internal Module state, shared by both nn.Module and ScriptModule.

### Class variables

var dump_patches : bool

Inherited from: DeepSurvivalMachinesTorch.dump_patches

dummy

var training : bool

Inherited from: DeepSurvivalMachinesTorch.training

dummy

### Methods

 def forward(self, x, risk='1') ‑> Callable[..., Any] 

Inherited from: DeepSurvivalMachinesTorch.forward

The forward function that is called when data is passed through DSM.

## Args

x: a torch.tensor of the input features.

 def get_shape_scale(self, risk='1') 
 class DeepCNNRNNSurvivalMachinesTorch (inputdim, k, typ='LSTM', layers=1, hidden=None, dist='Weibull', temp=1000.0, discount=1.0, optimizer='Adam', risks=1) 

A Torch implementation of Deep CNN Recurrent Survival Machines model.

This is an implementation of Deep Recurrent Survival Machines model in torch. It inherits from DeepSurvivalMachinesTorch 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.

Warning

Not designed to be used directly. Please use the API inferface dsm.DeepCNNRNNSurvivalMachines!!

## Parameters

inputdim : tuple
Dimensionality of the input features. (height, width)
k : int
The number of underlying parametric distributions.
layers : int
The number of hidden layers in the LSTM or RNN cell.
hidden : int
The number of neurons in each hidden layer.
init : tuple
A tuple for initialization of the parameters for the underlying distributions. (shape, scale).
dist : str
Choice of the underlying survival distributions. One of 'Weibull', 'LogNormal'. Default is 'Weibull'.
temp : float
The logits for the gate are rescaled with this value. Default is 1000.
discount : float
a float in [0,1] that determines how to discount the tail bias from the uncensored instances. Default is 1.

Initializes internal Module state, shared by both nn.Module and ScriptModule.

### Class variables

var dump_patches : bool

Inherited from: DeepRecurrentSurvivalMachinesTorch.dump_patches

dummy

var training : bool

Inherited from: DeepRecurrentSurvivalMachinesTorch.training

dummy

### Methods

 def forward(self, x, risk='1') ‑> Callable[..., Any] 

The forward function that is called when data is passed through DSM.

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.

## Args

x: a torch.tensor of the input features.

 def get_shape_scale(self, risk='1')