def visualize_model_performance( output_dir: str, domain_configs: List[DomainConfig], dataset_types: List[str] = None, device: str = "cuda:0", reduction: str = "umap", ): os.makedirs(output_dir, exist_ok=True) if dataset_types is None: dataset_types = ["train", "val"] for dataset_type in dataset_types: visualize_shared_latent_space( domain_configs=domain_configs, save_path=output_dir + "/shared_latent_space_{}_{}.png".format(reduction, dataset_type), dataset_type=dataset_type, random_state=42, reduction=reduction, device=device, ) # Todo resolve hacky try-catch way to avoid error if the domains consist of datasets of different sizes try: visualize_correlation_structure_latent_space( domain_configs=domain_configs, save_path=output_dir + "/latent_space_correlation_structure_{}.png".format( dataset_type), dataset_type=dataset_type, device=device, ) except ValueError: pass for domain_config in domain_configs: domain_name = domain_config.name for dataset_type in dataset_types: save_latents_to_csv( domain_config=domain_config, save_path=output_dir + "/{}_latent_representations_{}.csv".format( domain_name, dataset_type), dataset_type=dataset_type, device=device, ) visualize_single_domain_cycling_correlation_structure( domain_config=domain_config, dataset_type=dataset_type, save_path=output_dir + "/{}_cycling_correlation_structure_{}.png".format( domain_name, dataset_type), device=device, )
def save_latents_to_csv( self, domain_id: int = 0, dataset_type: str = "val", save_path: str = None, posfix: str = "", ): domain_config = self.domain_configs[domain_id] if save_path is None: save_path = os.path.join( self.output_dir, "latents_" + domain_config.name + "_" + dataset_type + posfix + ".csv", ) save_latents_to_csv( domain_config=domain_config, dataset_type=dataset_type, save_path=save_path, device=self.device, )
def visualize_model_performance( output_dir: str, domain_configs: List[DomainConfig], dataset_types: List[str] = None, device: str = "cuda:0", ): os.makedirs(output_dir, exist_ok=True) if dataset_types is None: dataset_types = ["train", "val"] for dataset_type in dataset_types: visualize_shared_latent_space( domain_configs=domain_configs, save_path=output_dir + "/shared_latent_space_umap_{}.png".format(dataset_type), dataset_type=dataset_type, random_state=42, reduction="umap", device=device, ) visualize_correlation_structure_latent_space( domain_configs=domain_configs, save_path=output_dir + "/latent_space_correlation_structure_{}.png".format(dataset_type), dataset_type=dataset_type, device=device, ) for domain_config in domain_configs: domain_name = domain_config.name for dataset_type in dataset_types: save_latents_to_csv( domain_config=domain_config, save_path=output_dir + "/{}_latent_representations_{}.csv".format(domain_name, dataset_type), dataset_type=dataset_type, device=device, )