예제 #1
0
def track_best(channel, save_path):
    tracker = TrackTheBest(channel, choose_best=min)
    checkpoint = saveload.Checkpoint(save_path,
                                     after_training=False,
                                     use_cpickle=True)
    checkpoint.add_condition(["after_epoch"],
                             predicate=predicates.OnLogRecord(
                                 '{0}_best_so_far'.format(channel)))
    return [tracker, checkpoint]
예제 #2
0
 def track_best(self, channel, save_path=None, choose_best=min):
     tracker = TrackTheBest(channel, choose_best=choose_best)
     self.extensions.append(tracker)
     if save_path:
         checkpoint = saveload.Checkpoint(save_path,
                                          after_training=False,
                                          use_cpickle=True)
         checkpoint.add_condition(["after_epoch"],
                                  predicate=predicates.OnLogRecord(
                                      '{0}_best_so_far'.format(channel)))
         self.extensions.append(checkpoint)
예제 #3
0
def track_best(channel, save_path, last_path, num_epochs, maxEpochs,
               maxIterations, epsilon, tempSharedData):
    tracker = TrackTheBest(channel)
    finishNoimprove = FinishIfNoImprovementEpsilonAfter(
        'valid_MRR_best_so_far', epochs=num_epochs, epsilon=epsilon)

    lastcheckpoint = myCheckpoint(last_path, tempSharedData)

    checkpoint = myCheckpoint(save_path,
                              tempSharedData,
                              after_training=False,
                              use_cpickle=True)
    checkpoint.add_condition(["after_epoch"],
                             predicate=predicates.OnLogRecord(
                                 '{0}_best_so_far'.format(channel)))
    finishAfter = FinishAfter(after_n_epochs=maxEpochs,
                              after_n_batches=maxIterations)

    return [tracker, finishNoimprove, lastcheckpoint, checkpoint, finishAfter]
예제 #4
0
    raise ValueError, conf.task
per_val_monitor = PER_Monitor(stream_val,
                              theano.function([x, x_m], y_hat_softmax),
                              before_first_epoch=True,
                              after_epoch=True,
                              prefix='valPER')
per_test_monitor = PER_Monitor(stream_test,
                               theano.function([x, x_m], y_hat_softmax),
                               before_first_epoch=False,
                               every_n_epochs=5,
                               prefix='testPER')

checkpoint = Checkpoint(conf.path_to_model, after_training=False)
checkpoint.add_condition(
    ['after_epoch'],
    predicate=predicates.OnLogRecord('valid_log_p_best_so_far'))
extensions = [
    val_monitor,
    train_monitor,
    per_val_monitor,
    per_test_monitor,
    Timing(),
    FinishAfter(after_n_epochs=conf.max_epochs),
    checkpoint,
    Printing(),
    TrackTheBest(record_name='val_monitor',
                 notification_name='valid_log_p_best_so_far'),
    FinishIfNoImprovementAfter(notification_name='valid_log_p_best_so_far',
                               epochs=conf.epochs_early_stopping),
]
main_loop = MainLoop(