TrainSegmentationNetwork[{inFol,outFol}]
trains a segmentation network from scratch. Training data should be wxf files in inFol. inFol can also be a list of folders, in which case wxf files from all folders are used. Progress is saved each round to outFol.
TrainSegmentationNetwork[{inFol,outFol},netCont]
continues training. netCont can be "Start" to restart, a NetGraph, a wlnet file, or a previous outFol to continue from the last saved network. Loss functions can be All or a subset of {"Dice", "Jaccard", "Tversky", "MSD", "CE", "Focal", "TopK"}. If MaskedPretraining->True self supervised pretraining is done instead: the network gets a single output channel, only the MSD and MAE losses are used, and the training data is masked and noise filled as generated by GetTrainData with MaskedPretraining->True.
TrainSegmentationNetwork
TrainSegmentationNetwork[{inFol,outFol}]
trains a segmentation network from scratch. Training data should be wxf files in inFol. inFol can also be a list of folders, in which case wxf files from all folders are used. Progress is saved each round to outFol.
TrainSegmentationNetwork[{inFol,outFol},netCont]
continues training. netCont can be "Start" to restart, a NetGraph, a wlnet file, or a previous outFol to continue from the last saved network. Loss functions can be All or a subset of {"Dice", "Jaccard", "Tversky", "MSD", "CE", "Focal", "TopK"}. If MaskedPretraining->True self supervised pretraining is done instead: the network gets a single output channel, only the MSD and MAE losses are used, and the training data is masked and noise filled as generated by GetTrainData with MaskedPretraining->True.
Details
- The following options can be given:
-
LoadTrainingData True LoadTrainingData is an option for TrainSegmentationNetwork. If set to True the training data is loaded from the disk. UseParallelKernels True UseParallelKernels is an option for TrainSegmentationNetwork. If set to True (default), producer kernels are launched as raw WSTP links, data loading and batch augmentation run on these separate kernels while NetTrain runs concurrently on its own kernel, which can substantially speed up training when augmentation is the bottleneck. If set to "Parallel", the older shared-queue Parallel-framework kernel pool is used instead. If set to {True, n} or {"Parallel", n} at most n producer kernels are used, useful for debugging on a small scale. If set to False batches are generated in-process. Monitor False Monitor[expr,mon] generates a temporary monitor cell in which the continually updated current value of mon is displayed during the course of evaluation of expr. MonitorInterval 2 MonitorInterval is an option for TrainSegmentationNetwork. It defines how often the training is monitored. PatchSize {32, 96, 96} PatchSize is an option for TrainSegmentationNetwork. Defines the patch size used in the network training. BatchSize 2 BatchSize is an option for NetTrain and related functions that specifies the size of a batch of examples to process together. PatchesPerSet 1 PatchesPerSet is an option for GetTrainData. Defines how many random patches per dataset are created within the batch. MultiChannel False MultiChannel is an option for TrainSegmentationNetwork, If set to True it will train on multi channel input data. If set to False it will select a random channel. AugmentData True AugmentData is an option for GetTrainData and TrainSegmentationNetwork. If set True the training data is augmented. It can also be set to "2D" or "3D" to control if augmentation is done through plane or only in-plane. PadData False PadData is an option for GetTrainData and TrainSegmentationNetwork.. If set to an integers the that number of slices on the top and bottom of the data can be made 0. This is done to learn cut of datasets. MaskedPretraining False MaskedPretraining is an option for GetTrainData and TrainSegmentationNetwork. If set to True self supervised masked-pretraining data/mode is used instead of segmentation data: the target becomes the clean data itself and the input is masked with noise filled blocks. RoundLength 256 RoundLength is an option for TrainSegmentationNetwork. Defines how many batches will be seen during each training round. MaxTrainingRounds 350 MaxTrainingRounds is an option for NetTrain and related functions that specifies the maximum number of rounds of training to do. RestartLearningCycle False RestartLearningCycle is an option for TrainSegmentationNetwork. If set to True and continuing training from a previous run, the one-cycle learning rate schedule (including its warmup) is restarted from 0 and fit to the remaining rounds, instead of resuming mid-cycle where the previous run left off. BlockType "ResNet" BlockType is an option for MakeUnet. It specifies the type of block used in the network. It can be "Conv", "UNet", "ResNet", "DenseNet", "Inception", or "U2Net". NetworkArchitecture "UNet" NetworkArchitecture is an option for MakeUnet. It defines the architecture of the network. It can be "UNet", "UNet+", or "UNet++". For "UNet+" or "UNet++" it can also be {arch, i} where i specifies how many of the top layers are connected to the mapping layer. ActivationType "GELU" ActivationType is an option for MakeUnet. It specifies which activation layer is used in the network. It can be "LeakyRELU" or any type allowed by a "name" definition in ElementwiseLayer. NormalizationType "Instance" NormalizationType is an option for MakeUnet. It specifies which normalization layer is used in the network. It can be "Batch" or "Instance" for either BatchNormalization or NormalizationLayer which is instance normalization. RescaleMethod "ConvS" RescaleMethod is an option for MakeUnet. It specifies how the network rescales. It can be "Conv" or "Pool". CatenateMethod "Tot" CatenateMethod is an option for MakeUnet. It specifies how the network catenates the skip and upscale channel. It can be "Tot", or "Cat". NetworkDepth 5 NetworkDepth is an option for MakeUnet. It specifies how deep the UNET will be. DownsampleSchedule 2 DownsampleSchedule is an option for MakeUnet. It defines how the data is downsampled for each of the deeper layers of the Unet. By default is is a factor two for each layer. A custom schedule for a 5 layer 3D Unet could be {{2,2,2},{1,2,2},{2,2,2},{1,2,2}, 1}. The deepest layer is always downsampled by 1 and therefore not needed to be specified. SettingSchedule Automatic SettingSchedule is an option for MakeUnet. It defines the settings for the Unet blocks. If one setting is given it applied to all layers. If a list of settings is given the settings can be different per layer. The following settings are the default settings. "Unet": convolution block repetitions, 2, "ResNet" -> convolution block repetitions, 2, "DenseNet" -> {dense depth, block repetitions}, {4,2}, "Inception" -> {inception width, block repetitions}, {4,2}, "U2Net"-> {Unet depth, downscale}, {5, True}. FeatureSchedule 32 FeatureSchedule is an option for MakeUnet. It defines how the number of features is up-sampled for each of the deeper layers of the Unet. By default it increases the number of features by a factor 2 each layer, i.e. {1, 2, 4, 8, 16}. LossFunction All LossFunction is an option for NetTrain that specifies how to compare actual and requested outputs from a neural net. DropoutRate 0.2 DropoutRate is an option for MakeUnet. It specifies how much dropout is used after each block. It is a value between 0 and 1, default is .2. LearningRate 0.001 LearningRate is an option for NetTrain that specifies the rate at which to adjust neural net weights in order to minimize the training loss. L2Regularization 0.0001 L2Regularization is an option for TrainSegmentationNetwork. It defines the L2 regularization factor. FreezeEncoderDepth None FreezeEncoderDepth is an option for TrainSegmentationNetwork. If set to an integer n, freezes the first n encoder blocks of a pretrained input network so their weights are not updated during training, useful for transfer learning from a pretrained encoder. Only applies when netCont is not "Start". Default is None, which trains all layers.