Exemplo n.º 1
0
 def __init__(self,
              batch_size=100,
              ini_learning_rate=0.001,
              max_epochs=100,
              patience=10,
              y_tensor_type=T.ivector,
              L2=1e-4,
              objective=mean_categorical_crossentropy,
              adapt_learn_rate=get_constant(),
              update_function=get_update_adam(),
              valid_batch_iter=get_batch_iterator(),
              train_batch_iter=get_batch_iterator(),
              use_weights=False,
              samples_per_epoch=None,
              shuffle_train=True,
              report_dices=False,
              use_mask=False,
              refinement_strategy=None):
     """
     Constructor
     """
     self.batch_size = batch_size
     self.ini_learning_rate = ini_learning_rate
     self.max_epochs = max_epochs
     self.patience = patience
     self.y_tensor_type = y_tensor_type
     self.L2 = L2
     self.objective = objective
     self.adapt_learn_rate = adapt_learn_rate
     self.update_function = update_function
     self.valid_batch_iter = valid_batch_iter
     self.train_batch_iter = train_batch_iter
     self.use_weights = use_weights
     self.samples_per_epoch = samples_per_epoch
     self.shuffle_train = shuffle_train
     self.report_dices = report_dices
     self.use_mask = use_mask
     self.refinement_strategy = refinement_strategy
     if refinement_strategy is None:
         self.refinement_strategy = RefinementStrategy()
Exemplo n.º 2
0
def get_batch_iterator():
    """
    Get batch iterator
    """

    def batch_iterator(batch_size, k_samples, shuffle):
        return BatchIterator(batch_size=batch_size, prepare=prepare, k_samples=k_samples, shuffle=shuffle)

    return batch_iterator


refinement_strategy = RefinementStrategy(n_refinement_steps=5, refinement_patience=5, learn_rate_multiplier=0.5)


train_strategy = TrainingStrategy(
    batch_size=SAMPLE_SIZE,
    ini_learning_rate=0.001,
    max_epochs=1000,
    patience=5,
    L2=None,
    samples_per_epoch=None,
    refinement_strategy=refinement_strategy,
    y_tensor_type=T.vector,
    objective=mean_pixel_binary_crossentropy,
    adapt_learn_rate=get_constant(),
    update_function=get_update_adam(),
    train_batch_iter=get_batch_iterator(),
    valid_batch_iter=get_batch_iterator()
)