niftynet.engine.application_driver module

This module defines a general procedure for running applications.

Example usage::
app_driver = ApplicationDriver() app_driver.initialise_application(system_param, input_data_param) app_driver.run_application()

system_param and input_data_param should be generated using: niftynet.utilities.user_parameters_parser.run()

class ApplicationDriver[source]

Bases: object

This class initialises an application by building a TF graph, and maintaining a session and coordinator. It controls the starting/stopping of an application. Applications should be implemented by inheriting niftynet.application.base_application to be compatible with this driver.

pre_train_iter = <blinker.base.NamedSignal object at 0x7f1d8c60b7d0; 'pre_train_iter'>
post_train_iter = <blinker.base.NamedSignal object at 0x7f1d8c60b8d0; 'post_train_iter'>
pre_validation_iter = <blinker.base.NamedSignal object at 0x7f1d8c60b910; 'pre_validation_iter'>
post_validation_iter = <blinker.base.NamedSignal object at 0x7f1d8c60b950; 'post_validation_iter'>
pre_infer_iter = <blinker.base.NamedSignal object at 0x7f1d8c60b990; 'pre_infer_iter'>
post_infer_iter = <blinker.base.NamedSignal object at 0x7f1d8c60b9d0; 'post_infer_iter'>
post_training = <blinker.base.NamedSignal object at 0x7f1d8c60ba10; 'post_training'>
initialise_application(workflow_param, data_param)[source]

This function receives all parameters from user config file, create an instance of application.

Parameters:
  • workflow_param – a dictionary of user parameters, keys correspond to sections in the config file
  • data_param – a dictionary of input image parameters, keys correspond to data properties to be used by image_reader
Returns:

run_application()[source]

Initialise a TF graph, connect data sampler and network within the graph context, run training loops or inference loops.

The training loop terminates when self.final_iter reached. The inference loop terminates when there is no more image sample to be processed from image reader.

Returns:
interleaved_iteration_generator()[source]

This generator yields a sequence of training and validation iterations

iter_generator(count_generator, phase)[source]

Generate a numbered sequence of IterationMessage objects with phase-appropriate signals. count_generator is an iterable object yielding iteration numbers phase is one of TRAIN, VALID or INFER

class ConsoleLogger(outputs_collector)[source]

Bases: object

This class handles iteration events to print output to the console

on_pre_iter(iter_msg)[source]

Event handler to add all the console output ops to the iteration message. iter_msg is an IterationMessage object

on_post_iter(iter_msg)[source]

Event handler to log the console outputs from the iteration message. iter_msg is an IterationMessage object

class ModelSaver(sess, saver, save_every_n, session_prefix)[source]

Bases: object

This class handles iteration events to save the model at regular intervals and at the end of training.

save_model_interval(iter_msg)[source]

Save the model if the iteration at at the specified interval iter_msg is an IterationMessage object

save_model(iter_msg)[source]

Save the model regardless of iteration iter_msg is an IterationMessage object

class TensorBoardLogger(outputs_collector, summary_dir, graph, tensorboard_every_n)[source]

Bases: object

This class handles iteration events to log summaries to the TensorBoard log.

filter(iter_msg)[source]

Decide whether to save a TensorBoard log entry for a given iteration. iter_msg is an IterationMessage object

on_pre_iter(iter_msg)[source]

Event handler to add all the TensorBoard summaries to the iteration message. iter_msg is an IterationMessage object

on_post_train_iter(iter_msg)[source]

Event handler to write the training TensorBoard log entry to disk. iter_msg is an IterationMessage object

on_post_validation_iter(iter_msg)[source]

Event handler to write the valiation TensorBoard log entry to disk. iter_msg is an IterationMessage object