msdnet.validate module

Module for defining and processing validation sets.

class msdnet.validate.Validation[source]

Bases: abc.ABC

Base class for processing a validation set.

abstract validate(n)[source]

Compute validation metrics.

Parameters

nnetwork.Network to validate with

Returns

True if validation metric is lower than best validation error encountered, False otherwise.

abstract to_dict()[source]

Compute validation metrics.

abstract load_dict(dct)[source]

Return a dictionary containing all network variables and parameters.

Returns

all network variables and parameters

abstract classmethod from_dict(dct)[source]

Initialize Validation object from dictionary.

Parameters

dct – dictionary with all parameters

classmethod from_file(fn)[source]

Initialize Validation object from file.

Parameters

fn – filename

to_file(fn)[source]

Save all Validation object parameters to file.

Parameters

fn – filename

class msdnet.validate.MetricValidation(data, keep=True)[source]

Bases: msdnet.validate.Validation

Validation object that computes simple difference metrics.

Parameters
  • data – list of data.DataPoint objects to validate with.

  • keep – (optional) whether to keep the best, worst, and typical result in memory.

errorfunc(output, target, msk)[source]

Error function used for validation.

Parameters
  • output – network output image.

  • target – target image.

  • mask – mask image to indicate where to compute error function for.

Returns

error function value.

getbest()[source]

Return the input, target, and network output for best result.

Returns

list of images (input, target, network output)

getworst()[source]

Return the input, target, and network output for worst result.

Returns

list of images (input, target, network output)

getmedian()[source]

Return the input, target, and network output for median result.

Returns

list of images (input, target, network output)

validate(n)[source]

Compute validation metrics.

Parameters

nnetwork.Network to validate with

Returns

True if validation metric is lower than best validation error encountered, False otherwise.

to_dict()[source]

Compute validation metrics.

load_dict(dct)[source]

Return a dictionary containing all network variables and parameters.

Returns

all network variables and parameters

classmethod from_dict(dct)[source]

Initialize Validation object from dictionary.

Parameters

dct – dictionary with all parameters

class msdnet.validate.MSEValidation(data, keep=True)[source]

Bases: msdnet.validate.MetricValidation

Validation object that uses mean-squared error

errorfunc(output, target, msk)[source]

Error function used for validation.

Parameters
  • output – network output image.

  • target – target image.

  • mask – mask image to indicate where to compute error function for.

Returns

error function value.