ClassifierTrainer¶
-
class
scvi.inference.
ClassifierTrainer
(*args, train_size=0.9, test_size=None, sampling_model=None, sampling_zl=False, use_cuda=True, **kwargs)[source]¶ Bases:
scvi.inference.trainer.Trainer
Class for training a classifier either on the raw data or on top of the latent space of another model.
- Parameters
model – A model instance from class
VAE
,VAEC
,SCANVI
gene_dataset – A gene_dataset instance like
CortexDataset()
train_size – The train size, a float between 0 and 1 representing proportion of dataset to use for training to use Default:
0.9
.test_size – The test size, a float between 0 and 1 representing proportion of dataset to use for testing to use Default:
None
.sampling_model – Model with z_encoder with which to first transform data.
sampling_zl – Transform data with sampling_model z_encoder and l_encoder and concat.
**kwargs – Other keywords arguments from the general Trainer class.
Examples
>>> gene_dataset = CortexDataset() >>> vae = VAE(gene_dataset.nb_genes, n_batch=gene_dataset.n_batches * False, ... n_labels=gene_dataset.n_labels)
>>> classifier = Classifier(vae.n_latent, n_labels=cortex_dataset.n_labels) >>> trainer = ClassifierTrainer(classifier, gene_dataset, sampling_model=vae, train_size=0.5) >>> trainer.train(n_epochs=20, lr=1e-3) >>> trainer.test_set.accuracy()
Attributes Summary
Methods Summary
compute_predictions
([soft])- param soft
(Default value = False)
loss
(tensors_labelled)Attributes Documentation
-
posteriors_loop
¶
Methods Documentation