return_01c=False, return_list=False, use_threads=use_threads, preload=True, n_layers=n_layers) n_batches_train = train_iter.nbatches n_batches_val = val_iter.nbatches n_classes = 2 void_labels = train_iter.void_labels # Define model simple_net_output, net = build_simple_model(input_var, filter_size=filter_size, n_filters=n_filters, depth=depth, block=block, nb_in_channels=nb_in_channels, n_classes=n_classes) # load weights to balance training error Class = np.loadtxt( '/Tmp/cucurulg/datasets/cortical_layers/6layers_segmentation/training_cls.txt' ) def compute_class_weights(Class): #get unique labels and number of pixels of each class unique, counts = np.unique(Class, return_counts=True) #calculate freq(c) number of pixels per class divided by the total number of pixels in images where c is present freq = counts.astype(float) / Class.size
shuffle_at_each_epoch = True, return_one_hot=False, return_01c=False, return_list=False, use_threads=use_threads, preload=True, n_layers=args['n_layers']) n_batches_val = val_iter.nbatches n_classes = val_iter.non_void_nclasses void_labels = val_iter.void_labels simple_net_output, net = build_simple_model(input_var, filter_size = args['filter_size'], n_filters = args['n_filters'], depth = args['depth'], block= args['block'], nb_in_channels = nb_in_channels, n_classes = n_classes) Class=np.loadtxt('/Tmp/cucurulg/datasets/cortical_layers/6layers_segmentation/training_cls.txt') def compute_class_weights(Class): #get unique labels and number of pixels of each class unique, counts = np.unique(Class,return_counts=True) #calculate freq(c) number of pixels per class divided by the total number of pixels in images where c is present freq=counts.astype(float)/Class.size return np.median(freq)/freq weights=compute_class_weights(Class) print "Defining and compiling valid functions"