Skip to content

Instantly share code, notes, and snippets.

@meghbhalerao
Created September 14, 2020 11:53
Show Gist options
  • Select an option

  • Save meghbhalerao/5a404d7709094daa11a573f82f62f017 to your computer and use it in GitHub Desktop.

Select an option

Save meghbhalerao/5a404d7709094daa11a573f82f62f017 to your computer and use it in GitHub Desktop.
# Choose the segmentation model here
# options: unet, resunet, fcn
model:
{
architecture: resunet,
final_layer: softmax
}
# Set base filters: number of filters present in the initial module of the U-Net convolution; for IncU-Net, keep this divisible by 4
base_filters: 30
# Set the list of labels the model should train on and predict
class_list: [0,1]
# Patch size during training - 2D patch for breast images since third dimension is not patched
patch_size: [304,304,32]
# Number of epochs
num_epochs: 200
# Set the batch size
batch_size: 1
# Set the initial learning rate
learning_rate: 0.1
# Learning rate scheduler - options: triangle, exp, reduce-on-lr, step, more to come soon - default hyperparameters can be changed thru code
scheduler: triangle
# Set which loss function you want to use - options : 'dc' - for dice only, 'dcce' - for sum of dice and CE and you can guess the next (only lower-case please)
# options: dc (dice only), ce (), dcce (sume of dice and ce), mse (), ...
loss_function: dc
# Which optimizer do you want to use - adam/sgd
opt: adam
# the value of 'k' for cross-validation, this is the percentage of total training data to use as validation;
# randomized split is performed using sklearn's KFold method
# for single fold run, use '-' before the fold number
kcross_validation: 7
# various data augmentation techniques
# options: affine, elastic, downsample, motion, ghosting, bias, blur, gaussianNoise, swap
# keep/edit as needed
# all transforms: https://torchio.readthedocs.io/transforms/transforms.html?highlight=transforms
# 'normalize': performs z-score normalization: https://torchio.readthedocs.io/transforms/preprocessing.html?highlight=ToCanonical#torchio.transforms.ZNormalization
# 'resample: resolution: X,Y,Z': resample the voxel resolution: https://torchio.readthedocs.io/transforms/preprocessing.html?highlight=ToCanonical#torchio.transforms.Resample
# 'resample: resolution: X': resample the voxel resolution in an isotropic manner: https://torchio.readthedocs.io/transforms/preprocessing.html?highlight=ToCanonical#torchio.transforms.Resample
# 'spatial': one of affine or elastic is picked (randomly) for augmentation
# 'kspace': one of motion or ghosting is picked (randomly) for augmentation
# 'probability' subkey adds the probability of the particular augmentation getting added during training (this is always 1 for normalize and resampling)
data_augmentation:
{
'spatial':{
'probability': 0.1
},
'kspace':{
'probability': 0.1
},
'bias':{'probability': 0.1},
'blur':{'probability': 0.1},
'noise':{'probability': 0.1},
'swap':{'probability': 0.1}
}
# parallel training on HPC - here goes the command to prepend to send to a high performance computing
# cluster for parallel computing during multi-fold training
# not used for single fold training
# this gets passed before the training_loop, so ensure enough memory is provided along with other parameters
# that your HPC would expect
# ${outputDir} will be changed to the outputDir you pass in CLI + '/${fold_number}'
# ensure that the correct location of the virtual environment is getting invoked, otherwise it would pick up the system python, which might not have all dependencies
parallel_compute_command: 'qsub -b y -l gpu -l h_vmem=45G -cwd -o ${outputDir}/$JOB_ID.stdout -e ${outputDir}/$JOB_ID.stderr /cbica/home/bhaleram/comp_space/ispy-seg/GANDLF/expts/sge_wrapper ~/.conda/envs/dss/bin/python'
## queue configuration - https://torchio.readthedocs.io/data/patch_training.html?#queue
# this determines the maximum number of patches that can be stored in the queue. Using a large number means that the queue needs to be filled less often, but more CPU memory is needed to store the patches
q_max_length: 1
# this determines the number of patches to extract from each volume. A small number of patches ensures a large variability in the queue, but training will be slower
q_samples_per_volume: 1
# this determines the number subprocesses to use for data loading; '0' means main process is used
q_num_workers: 4
# used for debugging
q_verbose: False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment