scmg.model.manifold_generation module
- scmg.model.manifold_generation.sinusoidal_embedding(n, d)
Create sinusoidal embeddings.
- class scmg.model.manifold_generation.ConditionalDiffusionModel(n_feature, n_time_feature, condition_classes, n_condition_feature, n_steps=1000, min_beta=0.0001, max_beta=0.02, n_network_blocks=3)
Bases:
ModuleA denoise diffusion model.
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x0, t, eta=None)
Add noise to the data. x0 has shape (n_batch, n_feature) and t has shape (n_batch,).
- backward(x, t, x_cond)
Predict the mean of distribution at t-1 given the data at t.
- generate(x_cond)
Generate samples from the model.
- class scmg.model.manifold_generation.RecurrentBlock(n_input, n_output, n_hidden)
Bases:
ModuleA MLP style recurrent block.
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class scmg.model.manifold_generation.MLPDenoiser(n_feature, n_time_feature, n_condition_feature, n_hidden=2048, n_blocks=3)
Bases:
ModuleA simple MLP denoiser.
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x, t_emb, x_cond)
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- scmg.model.manifold_generation.train_diffusion_model(model, loader, num_epochs, output_path, lr=0.0001, loss_history=None)
Train the diffusion model.
- scmg.model.manifold_generation.generate_cells(model, cond_classes, batch_size=512)
Generate cells from the model.
- scmg.model.manifold_generation.generate_transition_cells(model, start_cell_type, end_cell_type, n_cells, batch_size=512)
Generate cells between two cell types.