Skip to content

Commit

Permalink
remove SSDA
Browse files Browse the repository at this point in the history
  • Loading branch information
camillebrianceau committed Oct 17, 2024
1 parent 20e7855 commit 4b18b01
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 903 deletions.
45 changes: 0 additions & 45 deletions clinicadl/commandline/modules_options/ssda.py

This file was deleted.

7 changes: 0 additions & 7 deletions clinicadl/commandline/pipelines/train/classification/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
optimizer,
reproducibility,
split,
ssda,
transforms,
validation,
)
Expand Down Expand Up @@ -63,12 +62,6 @@
@dataloader.batch_size
@dataloader.sampler
@dataloader.n_proc
# ssda option
@ssda.ssda_network
@ssda.caps_target
@ssda.tsv_target_lab
@ssda.tsv_target_unlab
@ssda.preprocessing_json_target
# Cross validation
@split.n_splits
@split.split
Expand Down
7 changes: 0 additions & 7 deletions clinicadl/commandline/pipelines/train/reconstruction/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
optimizer,
reproducibility,
split,
ssda,
transforms,
validation,
)
Expand Down Expand Up @@ -63,12 +62,6 @@
@dataloader.batch_size
@dataloader.sampler
@dataloader.n_proc
# ssda option
@ssda.ssda_network
@ssda.caps_target
@ssda.tsv_target_lab
@ssda.tsv_target_unlab
@ssda.preprocessing_json_target
# Cross validation
@split.n_splits
@split.split
Expand Down
7 changes: 0 additions & 7 deletions clinicadl/commandline/pipelines/train/regression/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
optimizer,
reproducibility,
split,
ssda,
transforms,
validation,
)
Expand Down Expand Up @@ -61,12 +60,6 @@
@dataloader.batch_size
@dataloader.sampler
@dataloader.n_proc
# ssda o
@ssda.ssda_network
@ssda.caps_target
@ssda.tsv_target_lab
@ssda.tsv_target_unlab
@ssda.preprocessing_json_target
# Cross validation
@split.n_splits
@split.split
Expand Down
41 changes: 0 additions & 41 deletions clinicadl/config/config/ssda.py

This file was deleted.

1 change: 0 additions & 1 deletion clinicadl/nn/networks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
resnet18,
)
from .random import RandomArchitecture
from .ssda import Conv5_FC3_SSDA
from .unet import UNet
from .vae import (
CVAE_3D,
Expand Down
79 changes: 0 additions & 79 deletions clinicadl/predictor/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,85 +1044,6 @@ def _test_loader(
data_group=data_group,
)

def _test_loader_ssda(
self,
maps_manager: MapsManager,
dataloader,
criterion,
alpha,
data_group,
split,
selection_metrics,
use_labels=True,
gpu=None,
network=None,
target=False,
report_ci=True,
):
"""
Launches the testing task on a dataset wrapped by a DataLoader and writes prediction TSV files.
Args:
dataloader (torch.utils.data.DataLoader): DataLoader wrapping the test CapsDataset.
criterion (torch.nn.modules.loss._Loss): optimization criterion used during training.
data_group (str): name of the data group used for the testing task.
split (int): Index of the split used to train the model tested.
selection_metrics (list[str]): List of metrics used to select the best models which are tested.
use_labels (bool): If True, the labels must exist in test meta-data and metrics are computed.
gpu (bool): If given, a new value for the device of the model will be computed.
network (int): Index of the network tested (only used in multi-network setting).
"""
for selection_metric in selection_metrics:
log_dir = (
maps_manager.maps_path
/ f"split-{split}"
/ f"best-{selection_metric}"
/ data_group
)
maps_manager.write_description_log(
log_dir,
data_group,
dataloader.dataset.caps_dict,
dataloader.dataset.df,
)

# load the best trained model during the training
model, _ = maps_manager._init_model(
transfer_path=maps_manager.maps_path,
split=split,
transfer_selection=selection_metric,
gpu=gpu,
network=network,
)
prediction_df, metrics = self.test_da(
network_task=maps_manager.network_task,
model=model,
dataloader=dataloader,
criterion=criterion,
target=target,
report_ci=report_ci,
mode=maps_manager.mode,
metrics_module=maps_manager.metrics_module,
n_classes=maps_manager.n_classes,
)
if use_labels:
if network is not None:
metrics[f"{maps_manager.mode}_id"] = network

if report_ci:
loss_to_log = metrics["Metric_values"][-1]
else:
loss_to_log = metrics["loss"]

logger.info(
f"{maps_manager.mode} level {data_group} loss is {loss_to_log} for model selected on {selection_metric}"
)

# Replace here
maps_manager._mode_level_to_tsv(
prediction_df, metrics, split, selection_metric, data_group=data_group
)

@torch.no_grad()
def _compute_output_tensors(
self,
Expand Down
1 change: 0 additions & 1 deletion clinicadl/random_search/random_search_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ def random_sampling(rs_options: Dict[str, Any]) -> Dict[str, Any]:
"mode": "fixed",
"multi_cohort": "fixed",
"multi_network": "choice",
"ssda_netork": "fixed",
"n_fcblocks": "randint",
"n_splits": "fixed",
"n_proc": "fixed",
Expand Down
1 change: 0 additions & 1 deletion clinicadl/resources/config/train_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[Model]
architecture = "default" # ex : Conv5_FC3
multi_network = false
ssda_network = false

[Architecture]
# CNN
Expand Down
4 changes: 0 additions & 4 deletions clinicadl/trainer/config/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from clinicadl.caps_dataset.dataloader_config import DataLoaderConfig
from clinicadl.config.config.lr_scheduler import LRschedulerConfig
from clinicadl.config.config.reproducibility import ReproducibilityConfig
from clinicadl.config.config.ssda import SSDAConfig
from clinicadl.maps_manager.config import MapsManagerConfig
from clinicadl.network.config import NetworkConfig
from clinicadl.optimizer.optimization import OptimizationConfig
Expand Down Expand Up @@ -50,7 +49,6 @@ class TrainConfig(BaseModel, ABC):
optimizer: OptimizerConfig
reproducibility: ReproducibilityConfig
split: SplitConfig
ssda: SSDAConfig
transfer_learning: TransferLearningConfig
transforms: TransformsConfig
validation: ValidationConfig
Expand All @@ -77,7 +75,6 @@ def __init__(self, **kwargs):
optimizer=kwargs,
reproducibility=kwargs,
split=kwargs,
ssda=kwargs,
transfer_learning=kwargs,
transforms=kwargs,
validation=kwargs,
Expand All @@ -97,7 +94,6 @@ def _update(self, config_dict: Dict[str, Any]) -> None:
self.optimizer.__dict__.update(config_dict)
self.reproducibility.__dict__.update(config_dict)
self.split.__dict__.update(config_dict)
self.ssda.__dict__.update(config_dict)
self.transfer_learning.__dict__.update(config_dict)
self.transforms.__dict__.update(config_dict)
self.validation.__dict__.update(config_dict)
Expand Down
Loading

0 comments on commit 4b18b01

Please sign in to comment.