File size: 1,684 Bytes
0387745 232c308 0387745 232c308 0387745 232c308 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | import os
import torch
# Check if CUDA (GPU) is available and set the device accordingly
use_cuda = torch.cuda.is_available()
device = torch.device("cuda" if use_cuda else "cpu")
# Number of worker threads for data loading (safe auto-detection for laptop/server)
_cpu_avail = os.cpu_count() or 4
n_threads = 4 if (os.name == 'nt' or _cpu_avail <= 8) else 12
# Number of processes for multiprocessing (if applicable)
num_processes = n_threads
# Base batch size for training each individual task.
# For each task, we apply oversampling by selecting one sample with label 0 and one sample with label 1 per batch.
# The effective total batch size is batch_size * 6, accounting for the tasks 1p19q, IDH, and LHG.
batch_size = 1
# Random seed for reproducibility
random_seed = 1337
# Learning rate for the optimizer
lr_self = 1e-4
# Minimum learning rate for the learning rate scheduler
min_lr = 1e-6
# Weight decay (L2 regularization) to prevent overfitting
weight_decay = 2e-5
# Factor by which the learning rate will be reduced
lr_reduce_factor = 0.7
# Number of epochs with no improvement after which the learning rate will be reduced
lr_reduce_patience = 8
# Number of epochs for the first training stage
epochs_s1 = 60
# Number of epochs for the second training stage
epochs_s2 = 40
# Epoch number from which to start saving the model
save_epoch = 0
# Directory path where data and results will be stored
data_dir = './'
# Flag to enable or disable random operations (e.g., data shuffling)
random_flag = True
# W&B Settings
wandb_project = "CMTLNet-Training"
wandb_entity = None # Or your username
resume_checkpoint = None # Path to checkpoint to resume from, or None
|