Drawing

from deeptool.parameters import get_all_args
from deeptool.dataloader import load_test_batch

args = get_all_args()
args.model_type = "rnnvae"
args.batch_size = 1
args.track = False
batch = load_test_batch(args)
batch["img"].shape
torch.Size([1, 3, 16, 256, 256])

mod_batch_2d[source]

mod_batch_2d(batch)

transform the batch to be compatible with the network

mod_batch_3d[source]

mod_batch_3d(batch, key='img')

transform the batch to be compatible with the network by permuting

batchmod = mod_batch_3d(batch)
batchmod["img"].shape
torch.Size([16, 3, 256, 256])

class Transition[source]

Transition(args) :: Module

Transition Network with Recurrence / 1D Convolutions / Identity Function

The Simple Autoencoder with Recurrence

class RNNAE[source]

RNNAE(device, args) :: AbsModel

This class contains the general architecture and functionality to deal with all Models in this library contains: Tracker -> to visualize the progress Prep-input -> to handle the input depending on the dataset smootly

trans = nn.Sequential()
a = 5
trans(a) == a
True
args.rnn_transition = "cnn"
x = torch.randn(100, 34)
tran = Transition(args)
print(tran(x).shape)
tran
Transition: cnn
torch.Size([34, 100])
Transition(
  (main_part): Sequential(
    (0): Conv1d(100, 100, kernel_size=(3,), stride=(1,), padding=(1,))
    (1): ReLU()
  )
)
args.model_type = "rnnvae"
args.dataset_type = "MRNet"
args.rnn_type = "ae"
args.dim = 3
args = compat_args(args)
test_one_batch(args)
Model-Type: rnnvae
ae
Transition: cnn

The Variational Autoencoder in RNN Mode

class RNNVAE[source]

RNNVAE(device, args) :: RNNAE

inherit from RNN_AE and add the variational part

args.model_type = "rnnvae"
args.rnn_type = "vae"
args.dim = 3
args = compat_args(args)
test_one_batch(args)
Model-Type: rnnvae
vae
Transition: cnn

The Intro-VAE with RNN

class RNNINTROVAE[source]

RNNINTROVAE(device, args) :: RNNVAE

inherit from RNN_VAE and add the GAN part

args.model_type = "rnnvae"
args.rnn_type = "introvae"
args.dim = 3
args = compat_args(args)
test_one_batch(args)
Model-Type: rnnvae
introvae
Transition: cnn

Architecture:

Drawing

Loss:

Drawing

(by: https://arxiv.org/pdf/1907.02544.pdf)

class RNNBIGAN[source]

RNNBIGAN(device, args) :: RNNVAE

apply the Bidirectional-GAN part, inherit from the normal autoencoder

creator_rnn_ae[source]

creator_rnn_ae(device, args)

return an instance of the class depending on the mode set in args

device = torch.device(
    "cuda:0" if (torch.cuda.is_available() and args.n_gpu > 0) else "cpu"
)
rnn_bigan = RNNBIGAN(device, args)
data = load_test_batch(args)
x, tr = rnn_bigan(data, update=False)
x.shape
Transition: cnn
torch.Size([16, 3, 32, 32])