I’m developing a U_Net Model for Segmentation. My Train dataset shape is
[{'image', [32, 128, 128, 2]}; {'detection', [32, 128, 128, 2]}]
such that { 'image', [number of MRI slices, height, width, len(['T2W', 'ADC'])] } { 'detection', [number of MRI slices, height, width, number of classes ] }
.
I run this command:
!python .../Codes/train.py
--TRAIN_OBJ 'lesion'
--NUM_EPOCHS 3
--FOCAL_LOSS_ALPHA 0.3 0.7
--NAME .../Codes/RUN1
--TRAIN_XLSX_PREFIX .../Dataset_QIN/TrainFold3Dreduced
--VALID_XLSX_PREFIX .../Dataset_QIN/ValidFold3Dreduced
Such that “train.py” is as below:
# %%
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
import SimpleITK as sitk
import os
from os.path import join
import numpy as np
import scipy.ndimage
import time
from datetime import datetime
import cv2
import argparse
import json
import pandas as pd
from skimage.measure import regionprops
from scipy.stats import entropy
from shutil import copyfile, rmtree
import tensorflow as tf
import model.losses as losses
from model.augmentations import augment_tensors
import model.unets as unets
from callbacks import WeightsSaver, PCaDetectionValidation, AnatomySegmentationValidation,
ResumeTraining, ReduceLR_Schedule
from data_generators import custom_data_generator
from misc import setup_device, print_overview
import warnings
import multiprocessing
import pydicom as dicom
import keras
warnings.filterwarnings('ignore', '.*output shape of zoom.*')
# %%
# Command Line Arguments for Hyperparameters and I/O Paths
prsr = argparse.ArgumentParser(description='Command Line Arguments for Training Script')
#--------------------------------------------------------------------------------------------------
# Dataset Definition
prsr.add_argument('--TRAIN_OBJ', type=str, default='zonal', help="Training Objective: 'zonal'/'lesion'")
prsr.add_argument('--NAME', type=str, default='ZPX_P', help='Path to Load/Store Model Weights and Performance Metrics')
prsr.add_argument('--NUM_EPOCHS', type=int, default=150, help="Number of Training Epochs")
prsr.add_argument('--FOLDS', type=int, default=[0,1,2,3,4], nargs='+', help="Folds Selected For Training")
prsr.add_argument('--TRAIN_XLSX_PREFIX', type=str, default='ProstateX_train-fold-', help="Path+Prefix to Training Fold Files")
prsr.add_argument('--VALID_XLSX_PREFIX', type=str, default='ProstateX_valid-fold-', help="Path+Prefix to Validation Fold Files")
prsr.add_argument('--WEIGHTS_DIR', type=str, default='experiments', help="Path to Load/Store Model Weights")
prsr.add_argument('--METRICS_DIR', type=str, default='experiments', help="Path to Load/Store Performance Metrics")
prsr.add_argument('--USE_PRETRAINED_WEIGHTS', type=str, default=False, help="Path to Pretrained Weights or 'False' (Optional)")
prsr.add_argument('--FREEZE_LAYERS', type=int, default=9999, help="Freeze First N Layers when (USE_PRETRAINED_WEIGHTS!=9999) [e.g. 184]")
prsr.add_argument('--WEIGHTS_MIN_EPOCH', type=int, default=130, help="Minimum Epoch to Start Exporting Weights")
prsr.add_argument('--VALIDATE_PER_N_EPOCHS', type=int, default=5, help="Validate Model Performance Every N Epochs")
prsr.add_argument('--STORE_WEIGHTS_PER_N_EPOCHS', type=int, default=5, help="Store Weights Every N Epochs")
prsr.add_argument('--WEIGHTS_OVERWRITE', type=int, default=0, help="Store All Weights or Most Recent One")
prsr.add_argument('--VALIDATE_MIN_EPOCH', type=int, default=0, help="Minimum Epoch to Start Validation")
prsr.add_argument('--SHOW_SUMMARY', type=int, default=0, help="Display Overview")
prsr.add_argument('--RESUME_TRAIN', type=int, default=1, help="Enable Resume Training (Experimental)")
prsr.add_argument('--CACHE_TDS_PATH', type=str, default=None, help="Path to TensorFlow Data Cache for Faster I/O or 'False' (Optional)")
prsr.add_argument('--GPU_DEVICE_IDs', type=str, default="0", help="Number of GPUs Available for Computation")
#--------------------------------------------------------------------------------------------------
# U-Net Hyperparameters
prsr.add_argument('--UNET_DEEP_SUPERVISION', type=int, default=0, help="U-Net: Enable Deep Supervision")
prsr.add_argument('--UNET_PROBABILISTIC', type=int, default=0, help="U-Net: Enable Probabilistic/Bayesian Output Computation")
prsr.add_argument('--UNET_PROBA_EVENT_SHAPE', type=int, default=256, help="U-Net: Probabilistic Latent Distribution Size")
prsr.add_argument('--UNET_PROBA_ITER', type=int, default=1, help="U-Net: Iterations of Probabilistic Inference During Validation")
prsr.add_argument('--UNET_FEATURE_CHANNELS', type=int, default=[32,64,128,256,512], nargs='+', help="U-Net: Encoder/Decoder Channels")
prsr.add_argument('--UNET_STRIDES', type=int, default=[(1,1,1),(1,2,2),(1,2,2),(2,2,2),(2,2,2)], nargs='+', help="U-Net: Down/Upsampling Factor per Resolution")
prsr.add_argument('--UNET_KERNEL_SIZES', type=int, default=[(1,3,3),(1,3,3),(3,3,3),(3,3,3),(3,3,3)], nargs='+', help="U-Net: Convolution Kernel Sizes")
prsr.add_argument('--UNET_ATT_SUBSAMP', type=int, default=[(1,1,1),(1,1,1),(1,1,1),(1,1,1)], nargs='+', help="U-Net: Attention Gate Subsampling Factor")
prsr.add_argument('--UNET_SE_REDUCTION', type=int, default=[8,8,8,8,8], nargs='+', help="U-Net: Squeeze-and-Excitation Reduction Ratio")
prsr.add_argument('--UNET_KERNEL_REGULARIZER_L2', type=float, default=1e-5, help="U-Net: L2 Kernel Regularizer (Contributes to Total Loss at Train-Time)")
prsr.add_argument('--UNET_BIAS_REGULARIZER_L2', type=float, default=1e-5, help="U-Net: L2 Bias Regularizer (Contributes to Total Loss at Train-Time)")
prsr.add_argument('--UNET_DROPOUT_MODE', type=str, default="monte-carlo", help="U-Net: Dropout Mode: 'standard'/'monte-carlo'")
prsr.add_argument('--UNET_DROPOUT_RATE', type=float, default=0.33, help="U-Net: Dropout Regularization Rate")
#--------------------------------------------------------------------------------------------------
# Training Hyperparameters
prsr.add_argument('--BATCH_SIZE', type=int, default=1, help="Batch Size")
prsr.add_argument('--BASE_LR', type=float, default=1e-3, help="Base Learning Rate")
prsr.add_argument('--LR_MODE', type=str, default="CALR", help="Learning Rate Mode: 'CLR'/'CALR'")
prsr.add_argument('--CALR_PARAMS', type=float, default=[2.00, 1.00, 1e-3], nargs='+', help="'CosineDecayRestarts': t_mul, m_mul, alpha")
prsr.add_argument('--CLR_PARAMS', type=float, default=[5e-5, 1.00, 1.25], help="'CyclicLR': Max LR, Decay Factor, Step Factor")
prsr.add_argument('--OPTIMIZER', type=str, default="adam", help="Optimizer: 'adam'/'momentum'")
prsr.add_argument('--LOSS_MODE', type=str, default="distribution_focal", help="Loss: 'distribution_focal'/'region_boundary'")
prsr.add_argument('--FOCAL_LOSS_ALPHA', type=float, default=[0.05, 0.3, 0.65], nargs='+', help="Focal Loss (alpha)")
prsr.add_argument('--FOCAL_LOSS_GAMMA', type=float, default=0, help="Focal Loss (gamma). Note: When gamma=0; FL reduces down to CE/BCE.")
prsr.add_argument('--DSC_BD_LOSS_WEIGHTS', type=float, default=[0.50, 0.50], help="Soft Dice + Boundary Loss (weights)")
prsr.add_argument('--ELBO_LOSS_PARAMS', type=float, default=[1.0], help="Evidence Lower Bound Loss for Prob Dist. (weight)")
prsr.add_argument('--AUGM_PARAMS', type=float, default=[0.8, 0.25, 0.15, 10.0, True, 1.20, 0.10, 0.025, True,[0.5,1.5]], help="Train-Time Augmentations (M_PROB,TX_PROB,TRANS,ROT,HFLIP,SCALE,
NOISE,C_SHIFT,POOR_QUAL,GAMMA)")
#--------------------------------------------------------------------------------------------------
args, _ = prsr.parse_known_args()
# print(args)
CODE_BASE = os.path.abspath('/content/drive/MyDrive/MasterThesis/ProstateMR_USSL/Datasets.')
args.WEIGHTS_DIR = join(CODE_BASE, args.WEIGHTS_DIR)
args.METRICS_DIR = join(CODE_BASE, args.METRICS_DIR)
# For Each Fold
for f in args.FOLDS:
start_time = datetime.now()
# Verify Whether Training Had Completed (Yes -> Jump to Next Fold; No -> Resume/Restart Training)
if os.path.isfile(join(args.WEIGHTS_DIR, args.NAME, 'weights_f{}_{}.h5'.format(str(f), str({args.NUM_EPOCHS})))): continue
else: pass
#------------------------------------------------------------------------------------------------
# Dataset Definition
TRAIN_XLSX = join(CODE_BASE, 'data_feed', args.TRAIN_XLSX_PREFIX+str(f)+'.xlsx') # Paths to Training Scans/Labels
TRAIN_DATA_SAMPLES = len(pd.read_excel(TRAIN_XLSX)['image_path']) # Number of Training Samples
VALID_XLSX = join(CODE_BASE, 'data_feed', args.VALID_XLSX_PREFIX+str(f)+'.xlsx') # Paths to Training Scans/Labels
VALID_DATA_SAMPLES = len(pd.read_excel(VALID_XLSX)['image_path']) # Number of Training Samples
#------------------------------------------------------------------------------------------------
# Cosine Annealing Learning Rate (Cosine Decay w/ Warm Restarts)
if (args.LR_MODE=='CALR'):
BASE_LR = (tf.keras.optimizers.schedules.CosineDecayRestarts(
initial_learning_rate=args.BASE_LR, first_decay_steps=int(np.ceil(((TRAIN_DATA_SAMPLES)/args.BATCH_SIZE)))*args.NUM_EPOCHS,
t_mul=args.CALR_PARAMS[0], m_mul=args.CALR_PARAMS[1], alpha=args.CALR_PARAMS[2]))
print('CALR parameters', args.BASE_LR, args.CALR_PARAMS)
# Optimizer Setup
if (args.OPTIMIZER=='adam'): OPTIMIZER_SET = tf.keras.optimizers.Adam(learning_rate=BASE_LR, amsgrad=True)
elif (args.OPTIMIZER=='momentum'): OPTIMIZER_SET = tf.keras.optimizers.SGD(learning_rate=BASE_LR, nesterov=True, momentum=0.90)
# Segmentation/Detection Loss Function Setup
if (args.LOSS_MODE=='distribution_focal'): LOSSES = [losses.Focal(alpha=args.FOCAL_LOSS_ALPHA, gamma=args.FOCAL_LOSS_GAMMA).loss]
elif (args.LOSS_MODE=='region_boundary'): LOSSES = [losses.SoftDicePlusBoundarySurface(loss_weights=args.DSC_BD_LOSS_WEIGHTS).loss]
LOSS_WEIGHTS = [1.00]
# Loss Function for Probabilistic Setup
if bool(args.UNET_PROBABILISTIC):
LOSSES += [losses.EvidenceLowerBound().loss]
LOSS_WEIGHTS += [ELBO_LOSS_PARAMS[0]]
#------------------------------------------------------------------------------------------------
# Load Python Data Generators
print("Loading Training + Validation Data into RAM...")
# Define Channel Set
CHANNEL_SET = ['Apparent Diffusion Coefficient', 'T2 Weighted Axial']
train_data_gen = custom_data_generator(data_xlsx=TRAIN_XLSX, channel_set=CHANNEL_SET, train_obj=args.TRAIN_OBJ, probabilistic=bool(args.UNET_PROBABILISTIC))
valid_data_gen = custom_data_generator(data_xlsx=VALID_XLSX, channel_set=CHANNEL_SET, train_obj=args.TRAIN_OBJ, probabilistic=bool(args.UNET_PROBABILISTIC))
train_metrics = custom_data_generator(data_xlsx=TRAIN_XLSX, channel_set=CHANNEL_SET, train_obj=args.TRAIN_OBJ, probabilistic=bool(args.UNET_PROBABILISTIC))
print("Complete.")
#------------------------------------------------------------------------------------------------
#Assert Input Dimensions and Data Types via TensorFlow Datasets
IMAGE_SPATIAL_SHAPE = dicom.dcmread(pd.read_excel(TRAIN_XLSX)['image_path'][0]).pixel_array.shape # Spatial Dimensions of Input MRI (D,H,W)
DETECTION_SPATIAL_SHAPE = dicom.dcmread(pd.read_excel(TRAIN_XLSX)['label_path'][0]).pixel_array.shape
IMAGE_SPATIAL_DIMS = len(IMAGE_SPATIAL_SHAPE)
IMAGE_NUM_CHANNELS = (2 if args.TRAIN_OBJ=='lesion' else 1) # 'lesion':{T2W,ADC}, 'zonal':{T2W}
NUM_CLASSES = (2 if args.TRAIN_OBJ=='lesion' else 3) # 'lesion':{BG,csPCa},'zonal':{WG,TZ,PZ}
if ((args.LOSS_MODE)=='distribution_focal')&(len(args.FOCAL_LOSS_ALPHA)!=NUM_CLASSES):
raise Exception("Number of Class Weights Declared in Loss Function != Number of Classes in Labels/Loss Objective")
if bool(args.UNET_PROBABILISTIC): IMAGE_NUM_CHANNELS += NUM_CLASSES-1
if bool(args.UNET_PROBABILISTIC):
EXPECTED_IO_TYPE = ({"image": tf.float32},
{"detection": tf.float32,
"KL": tf.float32})
EXPECTED_IO_SHAPE = ({"image": (IMAGE_SPATIAL_DIMS + (IMAGE_NUM_CHANNELS,))},
{"detection": (IMAGE_SPATIAL_DIMS + (NUM_CLASSES,)),
"KL": IMAGE_SPATIAL_DIMS + (NUM_CLASSES,)})
else:
EXPECTED_IO_TYPE = ({"image": tf.float32},
{"detection": tf.float32})
EXPECTED_IO_SHAPE = ({"image": tf.TensorSpec(shape=IMAGE_SPATIAL_SHAPE +(IMAGE_NUM_CHANNELS,), dtype=tf.float32)},
{"detection": tf.TensorSpec(shape=(int(DETECTION_SPATIAL_SHAPE[0]/4), DETECTION_SPATIAL_SHAPE[1], DETECTION_SPATIAL_SHAPE[2])+(NUM_CLASSES,) , dtype=tf.float32)})
#------------------------------------------------------------------------------------------------
#TensorFlow GPU Handling + Datasets
devices, num_devices = setup_device(args.GPU_DEVICE_IDs)
if (num_devices>1): strategy = tf.distribute.MirroredStrategy(devices).scope()
else: strategy = tf.device(devices)
assert np.mod(args.BATCH_SIZE, num_devices)==0, 'Batch size (%d) should be a multiple of the number of GPUs (%d).'%(BATCH_SIZE, num_devices)
print("GPU Device(s):", devices)
#Switch I/O to TensorFlow Datasets
print("Switching I/O to TensorFlow Datasets...")
train_gen = tf.data.Dataset.from_generator(lambda:train_data_gen, output_signature=EXPECTED_IO_SHAPE) # Initialize TensorFlow Dataset
if str(args.CACHE_TDS_PATH)!='None':
train_gen = train_gen.cache(filename=(None if str(args.CACHE_TDS_PATH)=='None' else args.CACHE_TDS_PATH)) # Cache Dataset on Remote Server
# #Graph Mode: Disable Eager Execution and Enable @tf.function
# train_gen = train_gen.map(lambda x,y: augment_tensors(x,y,AUGM_PARAMS,True,TRAIN_OBJ))
#Eager Mode: Enable Eager Execution and Disable @tf.function
for data in train_gen.take(1):
features = data[0]
targets = data[1]
tf.print("Before augmentation - features shape:", str(tf.shape(features['image'])))
tf.print("Before augmentation - targets shape:", str(tf.shape(targets['detection'])))
features_new, targets_new = augment_tensors(features, targets, args.AUGM_PARAMS, True, args.TRAIN_OBJ)
train_gen = train_gen.map(lambda x, y : (features_new, targets_new))
train_gen = train_gen.shuffle(args.BATCH_SIZE*8) # Shuffle Samples
train_gen = train_gen.batch(args.BATCH_SIZE) # Load Data in Batches
train_gen = train_gen.prefetch(buffer_size=tf.data.AUTOTUNE) # Prefetch Data via CPU while GPU is Training
print("Complete.")
#------------------------------------------------------------------------------------------------
# Model Training/Validation
with strategy:
# U-Net Definition
unet_model = unets.networks.M1(input_spatial_shape = IMAGE_SPATIAL_SHAPE,
input_channels = IMAGE_NUM_CHANNELS,
num_classes = NUM_CLASSES,
filters = args.UNET_FEATURE_CHANNELS,
dropout_rate = args.UNET_DROPOUT_RATE,
strides = args.UNET_STRIDES,
kernel_sizes = args.UNET_KERNEL_SIZES,
dropout_mode = args.UNET_DROPOUT_MODE,
se_reduction = args.UNET_SE_REDUCTION,
att_sub_samp = args.UNET_ATT_SUBSAMP,
probabilistic = bool(args.UNET_PROBABILISTIC),
proba_event_shape = args.UNET_PROBA_EVENT_SHAPE,
deep_supervision = bool(args.UNET_DEEP_SUPERVISION),
summary = bool(args.SHOW_SUMMARY),
bias_initializer = tf.keras.initializers.TruncatedNormal(mean=0.0, stddev=0.001, seed=8),
bias_regularizer = tf.keras.regularizers.l2(args.UNET_BIAS_REGULARIZER_L2),
kernel_initializer = tf.keras.initializers.Orthogonal(gain=1.0, seed=8),
kernel_regularizer = tf.keras.regularizers.l2(args.UNET_KERNEL_REGULARIZER_L2))
# Display Number of Layers and Definition of Frozen Layers (If Any)
print("Number of Model Layers: ", len(unet_model.layers))
if args.FREEZE_LAYERS!=9999:
for layer in unet_model.layers[:args.FREEZE_LAYERS]: layer.trainable = False
print("Trainable Layers: ", len(unet_model.layers)-args.FREEZE_LAYERS)
for layer in unet_model.layers:
if layer.trainable==True: print(layer, layer.trainable)
# Load Pre-Trained Weights
if str(args.USE_PRETRAINED_WEIGHTS)!='False':
print('Loading pretrained weights from:', join(CODE_BASE, args.USE_PRETRAINED_WEIGHTS))
unet_model = unets.networks.M1.load(path=join(CODE_BASE, args.USE_PRETRAINED_WEIGHTS))
# Restart/Resume Training
if bool(args.RESUME_TRAIN):
if not os.path.exists(join(args.WEIGHTS_DIR, args.NAME,'f'+str(f))):
os.makedirs(join(args.WEIGHTS_DIR, args.NAME,'f'+str(f)))
unet_model, init_epoch = ResumeTraining(model=unet_model, weights_dir=join(args.WEIGHTS_DIR, args.NAME,'/f'+str(f)))
else:
init_epoch = 0
if os.path.exists(join(args.WEIGHTS_DIR, args.NAME,'f'+str(f))):
raise Exception("Target Folder Already Exists! Either Remove It or Enable 'RESUME_TRAIN'.")
else: os.makedirs(join(args.WEIGHTS_DIR, args.NAME,'f'+str(f)))
# Compile Model w/ Hyperparameters, Optimizer, Loss Functions
unet_model.compile(optimizer=OPTIMIZER_SET, loss=LOSSES, loss_weights=LOSS_WEIGHTS) #, run_eagerly=True
# Callbacks: Export Weights, Validate Model, Learning Rate Schedule
callbacks = [WeightsSaver(unet_model,
weights_overwrite = bool(args.WEIGHTS_OVERWRITE),
weights_dir = join(args.WEIGHTS_DIR, args.NAME,'f'+str(f)),
min_epoch = args.WEIGHTS_MIN_EPOCH,
weights_num_epochs = args.STORE_WEIGHTS_PER_N_EPOCHS,
init_epoch = init_epoch)]
if (args.TRAIN_OBJ=='zonal'):
callbacks += [AnatomySegmentationValidation(unet_model,
generators = [train_metrics, valid_data_gen],
min_epoch = args.VALIDATE_MIN_EPOCH,
every_n_epochs = args.VALIDATE_PER_N_EPOCHS,
num_samples = [TRAIN_DATA_SAMPLES, VALID_DATA_SAMPLES],
init_epoch = init_epoch,
export_metrics = join(args.METRICS_DIR, args.NAME,'f'+str(f)),
probabilistic = bool(args.UNET_PROBABILISTIC),
mc_dropout = (args.UNET_DROPOUT_MODE=='monte-carlo'),
prob_iterations = args.UNET_PROBA_ITER)]
if (args.TRAIN_OBJ=='lesion'):
callbacks += [PCaDetectionValidation(unet_model,
generators = [train_metrics, valid_data_gen],
min_epoch = args.VALIDATE_MIN_EPOCH,
every_n_epochs = args.VALIDATE_PER_N_EPOCHS,
num_samples = [TRAIN_DATA_SAMPLES, VALID_DATA_SAMPLES],
init_epoch = init_epoch,
export_metrics = join(args.METRICS_DIR, args.NAME,'f'+str(f)),
probabilistic = bool( args.UNET_PROBABILISTIC),
mc_dropout = (args.UNET_DROPOUT_MODE=='monte-carlo'),
prob_iterations = args.UNET_PROBA_ITER)]
if (args.LR_MODE=='CLR'):
callbacks += [CyclicLR(mode = 'exp_range',
max_lr = args.CLR_PARAMS[1],
gamma = args.CLR_PARAMS[2],
base_lr = BASE_LR,
step_size = (round(TRAIN_SAMPLES)//args.BATCH_SIZE)*args.CLR_PARAMS[3])]
# Train Model
keras.utils.plot_model(unet_model, show_shapes=True)
print()
history = unet_model.fit(x = train_gen,
epochs = args.NUM_EPOCHS,
steps_per_epoch = int(np.ceil(((TRAIN_DATA_SAMPLES)/args.BATCH_SIZE))),
initial_epoch = init_epoch,
verbose = 2,
callbacks = callbacks,
use_multiprocessing = True)
print('Fold {} Duration: {}'.format(str(f), datetime.now() - start_time))
print(30*'#')
print(30*'#')
print(30*'#')
#------------------------------------------------------------------------------------------------
# %%
I got this output
2024-08-11 11:44:36.451369: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-08-11 11:44:36.451424: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-08-11 11:44:36.452376: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-08-11 11:44:36.457771: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-08-11 11:44:37.474092: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
/usr/local/lib/python3.10/dist-packages/tensorflow_addons/utils/tfa_eol_msg.py:23: UserWarning:
TensorFlow Addons (TFA) has ended development and introduction of new features.
TFA has entered a minimal maintenance and release mode until a planned end of life in May 2024.
Please modify downstream libraries to take dependencies from other repositories in our TensorFlow community (e.g. Keras, Keras-CV, and Keras-NLP).
For more information see: https://github.com/tensorflow/addons/issues/2807
warnings.warn(
Namespace(TRAIN_OBJ='lesion', NAME='/content/drive/MyDrive/MasterThesis/ProstateMR_USSL/Codes/RUN1', NUM_EPOCHS=3, FOLDS=[0, 1, 2, 3, 4], TRAIN_XLSX_PREFIX='/content/drive/MyDrive/MasterThesis/ProstateMR_USSL/Dataset_QIN/TrainFold3Dreduced', VALID_XLSX_PREFIX='/content/drive/MyDrive/MasterThesis/ProstateMR_USSL/Dataset_QIN/ValidFold3Dreduced', WEIGHTS_DIR='experiments', METRICS_DIR='experiments', USE_PRETRAINED_WEIGHTS=False, FREEZE_LAYERS=9999, WEIGHTS_MIN_EPOCH=130, VALIDATE_PER_N_EPOCHS=5, STORE_WEIGHTS_PER_N_EPOCHS=5, WEIGHTS_OVERWRITE=0, VALIDATE_MIN_EPOCH=0, SHOW_SUMMARY=0, RESUME_TRAIN=1, CACHE_TDS_PATH=None, GPU_DEVICE_IDs='0', UNET_DEEP_SUPERVISION=0, UNET_PROBABILISTIC=0, UNET_PROBA_EVENT_SHAPE=256, UNET_PROBA_ITER=1, UNET_FEATURE_CHANNELS=[32, 64, 128, 256, 512], UNET_STRIDES=[(1, 1, 1), (1, 2, 2), (1, 2, 2), (2, 2, 2), (2, 2, 2)], UNET_KERNEL_SIZES=[(1, 3, 3), (1, 3, 3), (3, 3, 3), (3, 3, 3), (3, 3, 3)], UNET_ATT_SUBSAMP=[(1, 1, 1), (1, 1, 1), (1, 1, 1), (1, 1, 1)], UNET_SE_REDUCTION=[8, 8, 8, 8, 8], UNET_KERNEL_REGULARIZER_L2=1e-05, UNET_BIAS_REGULARIZER_L2=1e-05, UNET_DROPOUT_MODE='monte-carlo', UNET_DROPOUT_RATE=0.33, BATCH_SIZE=1, BASE_LR=0.001, LR_MODE='CALR', CALR_PARAMS=[2.0, 1.0, 0.001], CLR_PARAMS=[5e-05, 1.0, 1.25], OPTIMIZER='adam', LOSS_MODE='distribution_focal', FOCAL_LOSS_ALPHA=[0.3, 0.7], FOCAL_LOSS_GAMMA=0, DSC_BD_LOSS_WEIGHTS=[0.5, 0.5], ELBO_LOSS_PARAMS=[1.0], AUGM_PARAMS=[0.8, 0.25, 0.15, 10.0, True, 1.2, 0.1, 0.025, True, [0.5, 1.5]])
CALR parameters 0.001 [2.0, 1.0, 0.001]
Loading Training + Validation Data into RAM...
Complete.
GPU Device(s): /gpu:0
Switching I/O to TensorFlow Datasets...
Complete.
m1 Input Shape is : (None, 32, 128, 128, 2)
Input Volume:--------------------------- (None, 32, 128, 128, 2)
Initial Convolutional Layer (Stage 0):-- (None, 32, 128, 128, 32)
Attention Gating: Stage 0:-------------- (None, 32, 128, 128, 32)
Encoder: Stage 1; SE-Residual Block:---- (None, 32, 64, 64, 64)
Attention Gating: Stage 1:-------------- (None, 32, 64, 64, 64)
Encoder: Stage 2; SE-Residual Block:---- (None, 32, 32, 32, 128)
Attention Gating: Stage 2:-------------- (None, 32, 32, 32, 128)
Encoder: Stage 3; SE-Residual Block:---- (None, 16, 16, 16, 256)
Attention Gating: Stage 3:-------------- (None, 16, 16, 16, 256)
Middle: High-Dim Latent Features:------- (None, 8, 8, 8, 512)
Decoder: Stage 3; Nested U-Net:--------- (None, 16, 16, 16, 256)
Decoder: Stage 2; Nested U-Net:--------- (None, 32, 32, 32, 128)
Decoder: Stage 1; Nested U-Net:--------- (None, 32, 64, 64, 64)
Decoder: Stage 0; Nested U-Net:--------- (None, 32, 128, 128, 32)
U-Net [Logits]:------------------------- (None, 32, 128, 128, 2)
Deep Supervision Disabled
Number of Model Layers: 225
Begin Training @ Epoch 0
Epoch 1/3
^C
What is wrong with my code or data and what’s the meaning of “^C” at the end of output?
6