ShapeNetwork

class ShapeNetwork(layer_cls, layer_kwargs, in_channels=1, norm_type='instance', img_size=224, feature_extractor=None, **kwargs)[source]

Bases: shapenet.networks.abstract_network.AbstractShapeNetwork

Network to Predict a single shape

static closure(model, data_dict: dict, optimizers: dict, criterions={}, metrics={}, fold=0, **kwargs)[source]

closure method to do a single backpropagation step

Parameters:
  • model (ShapeNetwork) – trainable model
  • data_dict (dict) – dictionary containing the data
  • optimizers (dict) – dictionary of optimizers to optimize model’s parameters
  • criterions (dict) – dict holding the criterions to calculate errors (gradients from different criterions will be accumulated)
  • metrics (dict) – dict holding the metrics to calculate
  • fold (int) – Current Fold in Crossvalidation (default: 0)
  • **kwargs – additional keyword arguments
Returns:

  • dict – Metric values (with same keys as input dict metrics)
  • dict – Loss values (with same keys as input dict criterions)
  • list – Arbitrary number of predictions as torch.Tensor

Raises:

AssertionError – if optimizers or criterions are empty or the optimizers are not specified

forward(input_images)[source]

Forward input batch through network and shape layer

Parameters:input_images (torch.Tensor) – input batch
Returns:predicted shapes
Return type:torch.Tensor
model
static norm_type_to_class(norm_type)

helper function to map a string to an actual normalization class

Parameters:norm_type (str) – string specifying the normalization class
Returns:Normalization Class (subclass of torch.nn.Module)
Return type:type