msdnet.network module¶
Module implementing neural networks.
- 
class msdnet.network.Network[source]¶
- Bases: - abc.ABC- Base class for a neural network. - 
abstract forward(im, returnoutput=True)[source]¶
- Compute a forward pass of the network. - Parameters
- im – input image (channels x rows x columns) 
- returnoutput – whether to return the output image (default: True) 
 
- Returns
- output image (channels x rows x columns) 
 
 - 
abstract backward(im)[source]¶
- Compute a backpropagation pass of the network. Sensitivity maps of each intermediate image are stored within the network. - Parameters
- im – error gradient image (channels x rows x columns) 
 
 - 
abstract getgradients()[source]¶
- Return a flat array with all gradient variables. - Returns
- all gradient variables 
 
 - 
updategradients(u)[source]¶
- Update variables of network within a thread. - Parameters
- u – update variables 
 
 - 
abstract updategradients_internal(u)[source]¶
- Update variables of network. - Parameters
- u – update variables 
 
 - 
abstract to_dict()[source]¶
- Return a dictionary containing all network variables and parameters. - Returns
- all network variables and parameters 
 
 - 
abstract load_dict(dct)[source]¶
- Set all network variables and parameters from dictionary. - Parameters
- dct – all network variables and parameters 
 
 - 
abstract classmethod from_dict(dct, gpu=True)[source]¶
- Initialize network and all network variables and parameters from dictionary. - Parameters
- dct – all network variables and parameters 
 
 - 
classmethod from_file(fn, gpu=True, groupname='network')[source]¶
- Initialize network and all network variables and parameters from file. - Parameters
- fn – filename 
- gpu – (optional) whether to use GPU or CPU 
 
 
 
- 
abstract 
- 
class msdnet.network.MSDNet(d, dil, nin, nout, gpu=True)[source]¶
- Bases: - msdnet.network.Network- Main implementation of a Mixed-Scale Dense network. - Parameters
- d – depth of network (width is always 1) 
- dil – - dilations.Dilationsclass defining dilations
- nin – number of input channels 
- nout – number of output channels 
- gpu – (optional) whether to use GPU or CPU 
 
 - 
forward(im, returnoutput=True)[source]¶
- Compute a forward pass of the network. - Parameters
- im – input image (channels x rows x columns) 
- returnoutput – whether to return the output image (default: True) 
 
- Returns
- output image (channels x rows x columns) 
 
 - 
backward(im, inputdelta=False)[source]¶
- Compute a backpropagation pass of the network. Sensitivity maps of each intermediate image are stored within the network. - Parameters
- im – error gradient image (channels x rows x columns) 
 
 - 
getgradients()[source]¶
- Return a flat array with all gradient variables. - Returns
- all gradient variables 
 
 - 
normalizeinput(datapoints)[source]¶
- Normalize input of network to zero mean and unit variance. - Parameters
- datapoints – list of datapoints to compute normalization factors with. 
 
 - 
normalizeoutput(datapoints)[source]¶
- Normalize output of network to zero mean and unit variance. - Parameters
- datapoints – list of datapoints to compute normalization factors with. 
 
 - 
to_dict()[source]¶
- Return a dictionary containing all network variables and parameters. - Returns
- all network variables and parameters 
 
 
- 
class msdnet.network.SegmentationMSDNet(*args, **kwargs)[source]¶
- Bases: - msdnet.network.MSDNet- Main implementation of a Mixed-Scale Dense network for segmentation. - Same parameters as - MSDNet.