Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
vavali08 authored Aug 14, 2023
1 parent 22ca75f commit 4373ea5
Showing 1 changed file with 200 additions and 0 deletions.
200 changes: 200 additions & 0 deletions tutorials/classification_pathmnist_notebook/config (3).yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
# affix version
version:
{
minimum: 0.0.14,
maximum: 0.0.14 # this should NOT be made a variable, but should be tested after every tag is created
}
# Choose the model parameters here

model:
{
dimension: 2, # the dimension of the model and dataset: defines dimensionality of computations
base_filters: 32, # Set base filters: number of filters present in the initial module of the U-Net convolution; for IncU-Net, keep this divisible by 4
architecture: vgg, # options: unet, resunet, fcn, uinc, vgg, densenet
batch_norm: True, # this is only used for vgg
norm_type: batch,
final_layer: sigmoid, # can be either sigmoid, softmax or none (none == regression)
amp: False, # Set if you want to use Automatic Mixed Precision for your operations or not - options: True, False
n_channels: 3, # set the input channels - useful when reading RGB or images that have vectored pixel types
class_list: ["0", "1", "2", "3", "4", "5", "6", "7", "8"] # changed for pathmnist
}
# this is to enable or disable lazy loading - setting to true reads all data once during data loading, resulting in improvements
# in I/O at the expense of memory consumption
in_memory: False
# this will save the generated masks for validation and testing data for qualitative analysis
save_masks: False
# Set the Modality : rad for radiology, path for histopathology
modality: rad
# Patch size during training - 2D patch for breast images since third dimension is not patched
patch_size: [256, 256]
# uniform: UniformSampler or label: LabelSampler
patch_sampler: uniform
#metrics: ["classification_accuracy"]
#metrics: ["accuracy"]
metrics:
#- cel
- classification_accuracy
- f1: {
average: weighted,
}
- accuracy
- balanced_accuracy
# - precision: {
# average: weighted,
# }
# - recall
# - iou: {
# reduction: sum,
# }
# Number of epochs
num_epochs: 5
# Set the patience - measured in number of epochs after which, if the performance metric does not improve, exit the training loop - defaults to the number of epochs
patience: 5
# Set the batch size
batch_size: 16
# Set the initial learning rate
learning_rate: 0.001
# Learning rate scheduler - options: triangle, triangle_modified, 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), dc_log (-log of dice), ce (), dcce (sum of dice and ce), mse () ...
# mse is the MSE defined by torch and can define a variable 'reduction'; see https://pytorch.org/docs/stable/generated/torch.nn.MSELoss.html#torch.nn.MSELoss
# use mse_torch for regression/classification problems and dice for segmentation
loss_function: cel
# this parameter weights the loss to handle imbalanced losses better
weighted_loss: True
#loss_function:
# {
# 'mse':{
# 'reduction': 'mean' # see https://pytorch.org/docs/stable/generated/torch.nn.MSELoss.html#torch.nn.MSELoss for all options
# }
# }
# Which optimizer do you want to use - adam/sgd
opt: adam
# this parameter controls the nested training process
# performs randomized k-fold cross-validation
# split is performed using sklearn's KFold method
# for single fold run, use '-' before the fold number
nested_training:
{
testing: 1, # this controls the testing data splits for final model evaluation; use '1' if this is to be disabled
validation: -5 # this controls the validation data splits for model training
}
## pre-processing
# this constructs an order of transformations, which is applied to all images in the data loader
# order: resize --> threshold/clip --> resample --> normalize
# 'threshold': performs intensity thresholding; i.e., if x[i] < min: x[i] = 0; and if x[i] > max: x[i] = 0
# 'clip': performs intensity clipping; i.e., if x[i] < min: x[i] = min; and if x[i] > max: x[i] = max
# 'threshold'/'clip': if either min/max is not defined, it is taken as the minimum/maximum of the image, respectively
# 'normalize': performs z-score normalization: https://torchio.readthedocs.io/transforms/preprocessing.html?highlight=ToCanonical#torchio.transforms.ZNormalization
# 'normalize_nonZero': perform z-score normalize but with mean and std-dev calculated on only non-zero pixels
# 'normalize_nonZero_masked': perform z-score normalize but with mean and std-dev calculated on only non-zero pixels with the stats applied on non-zero pixels
# 'crop_external_zero_planes': crops all non-zero planes from input tensor to reduce image search space
# '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
# resize the image(s) and mask (this should be greater than or equal to patch_size); resize is done ONLY when resample is not defined


# data_augmentation:
# {
# # 'spatial':{
# # 'probability': 0.5
# # },
# # 'kspace':{
# # 'probability': 0.5
# # },
# 'bias':{
# 'probability': 0.5
# },
# 'blur':{
# 'probability': 0.5
# },
# 'noise':{
# 'probability': 0.5
# },
# 'swap':{
# 'probability': 0.5
# }
# }

data_preprocessing:
{
#'normalize_div_by_255',
# 'threshold':{
# 'min': 10,
# 'max': 75
# },
# 'clip':{
# 'min': 10,
# 'max': 75
# },
#'normalize_imagenet',
# 'resample':{
# 'resolution': [1,2,3]
# },
'resize': [256,256], # this is generally not recommended, as it changes image properties in unexpected ways
#'resize_image': [256,256], #resizes the image and mask BEFORE applying any another operation
#'resize_patch': [256,256] #resizes the image and mask AFTER extracting the patch
}
# data_preprocessing:
# {
# # 'normalize',
# # # 'normalize_nonZero', # this performs z-score normalization only on non-zero pixels
# # 'resample':{
# # 'resolution': [1,2,3]
# # },
#'resize': [128, 128], # this is generally not recommended, as it changes image properties in unexpected ways
# # 'crop_external_zero_planes', # this will crop all zero-valued planes across all axes
# }
# 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
# 'kspace': one of motion, ghosting or spiking 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:
# {
# default_probability: 0.5,
# 'affine',
# 'elastic',
# 'kspace':{
# 'probability': 1
# },
# 'bias',
# 'blur': {
# 'std': [0, 1] # default std-dev range, for details, see https://torchio.readthedocs.io/transforms/augmentation.html?highlight=randomblur#torchio.transforms.RandomBlur
# },
# 'noise': { # for details, see https://torchio.readthedocs.io/transforms/augmentation.html?highlight=randomblur#torchio.transforms.RandomNoise
# 'mean': 0, # default mean
# 'std': [0, 1] # default std-dev range
# },
# 'anisotropic':{
# 'axis': [0,1],
# 'downsampling': [2,2.5]
# },
# }
# 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

# UB_commented: parallel_compute_command: 'qsub -b y -l gpu -l h_vmem=32G -cwd -o ${outputDir}/\$JOB_ID.stdout -e ${outputDir}/\$JOB_ID.stderr `pwd`/sge_wrapper _correct_location_of_virtual_environment_/venv/bin/python',
#parallel_compute_command: ''
## 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: 5

# 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: 0 # scale this according to available CPU resources (was 16)

# used for debugging
q_verbose: False

0 comments on commit 4373ea5

Please sign in to comment.