Network¶
-
class
deepreg.model.network.
ConditionalModel
(*args: Any, **kwargs: Any)¶ A registration model predicts fixed image label without DDF or DVF.
Init.
- Parameters
moving_image_size – (m_dim1, m_dim2, m_dim3)
fixed_image_size – (f_dim1, f_dim2, f_dim3)
index_size – number of indices for identify each sample
labeled – if the data is labeled
batch_size – total number of samples consumed per step, over all devices. When using multiple devices, TensorFlow automatically split the tensors. Therefore, input shapes should be defined over batch_size.
config – config for method, backbone, and loss.
name – name of the model
-
build_model
()¶ Build the model to be saved as self._model.
-
postprocess
(inputs: Dict[str, tensorflow.Tensor], outputs: Dict[str, tensorflow.Tensor]) → Tuple[tensorflow.Tensor, Dict]¶ Return a dict used for saving inputs and outputs.
- Parameters
inputs – dict of model inputs
outputs – dict of model outputs
- Returns
tuple, indices and a dict. In the dict, each value is (tensor, normalize, on_label), where - normalize = True if the tensor need to be normalized to [0, 1] - on_label = True if the tensor depends on label
-
class
deepreg.model.network.
DDFModel
(*args: Any, **kwargs: Any)¶ A registration model predicts DDF.
When using global net as backbone, the model predicts an affine transformation parameters, and a DDF is calculated based on that.
Init.
- Parameters
moving_image_size – (m_dim1, m_dim2, m_dim3)
fixed_image_size – (f_dim1, f_dim2, f_dim3)
index_size – number of indices for identify each sample
labeled – if the data is labeled
batch_size – total number of samples consumed per step, over all devices. When using multiple devices, TensorFlow automatically split the tensors. Therefore, input shapes should be defined over batch_size.
config – config for method, backbone, and loss.
name – name of the model
-
build_loss
()¶ Build losses according to configs.
-
build_model
()¶ Build the model to be saved as self._model.
-
postprocess
(inputs: Dict[str, tensorflow.Tensor], outputs: Dict[str, tensorflow.Tensor]) → Tuple[tensorflow.Tensor, Dict]¶ Return a dict used for saving inputs and outputs.
- Parameters
inputs – dict of model inputs
outputs – dict of model outputs
- Returns
tuple, indices and a dict. In the dict, each value is (tensor, normalize, on_label), where - normalize = True if the tensor need to be normalized to [0, 1] - on_label = True if the tensor depends on label
-
class
deepreg.model.network.
DVFModel
(*args: Any, **kwargs: Any)¶ A registration model predicts DVF.
DDF is calculated based on DVF.
Init.
- Parameters
moving_image_size – (m_dim1, m_dim2, m_dim3)
fixed_image_size – (f_dim1, f_dim2, f_dim3)
index_size – number of indices for identify each sample
labeled – if the data is labeled
batch_size – total number of samples consumed per step, over all devices. When using multiple devices, TensorFlow automatically split the tensors. Therefore, input shapes should be defined over batch_size.
config – config for method, backbone, and loss.
name – name of the model
-
build_loss
()¶ Build losses according to configs.
-
build_model
()¶ Build the model to be saved as self._model.
-
postprocess
(inputs: Dict[str, tensorflow.Tensor], outputs: Dict[str, tensorflow.Tensor]) → Tuple[tensorflow.Tensor, Dict]¶ Return a dict used for saving inputs and outputs.
- Parameters
inputs – dict of model inputs
outputs – dict of model outputs
- Returns
tuple, indices and a dict. In the dict, each value is (tensor, normalize, on_label), where - normalize = True if the tensor need to be normalized to [0, 1] - on_label = True if the tensor depends on label
-
class
deepreg.model.network.
RegistrationModel
(*args: Any, **kwargs: Any)¶ Interface for registration model.
Init.
- Parameters
moving_image_size – (m_dim1, m_dim2, m_dim3)
fixed_image_size – (f_dim1, f_dim2, f_dim3)
index_size – number of indices for identify each sample
labeled – if the data is labeled
batch_size – total number of samples consumed per step, over all devices. When using multiple devices, TensorFlow automatically split the tensors. Therefore, input shapes should be defined over batch_size.
config – config for method, backbone, and loss.
name – name of the model
-
build_inputs
() → Dict[str, tensorflow.keras.layers.Input]¶ Build input tensors.
- Returns
dict of inputs.
-
abstract
build_loss
()¶ Build losses according to configs.
-
abstract
build_model
()¶ Build the model to be saved as self._model.
-
call
(inputs: Dict[str, tensorflow.Tensor], training=None, mask=None) → Dict[str, tensorflow.Tensor]¶ Call the self._model.
- Parameters
inputs – a dict of tensors.
training – training or not.
mask – maks for inputs.
- Returns
-
concat_images
(moving_image: tensorflow.Tensor, fixed_image: tensorflow.Tensor, moving_label: Optional[tensorflow.Tensor] = None) → tensorflow.Tensor¶ Adjust image shape and concatenate them together.
- Parameters
moving_image – registration source
fixed_image – registration target
moving_label – optional, only used for conditional model.
- Returns
-
get_config
() → dict¶ Return the config dictionary for recreating this class.
-
log_tensor_stats
(tensor: tensorflow.Tensor, name: str)¶ Log statistics of a given tensor.
- Parameters
tensor – tensor to monitor.
name – name of the tensor.
-
plot_model
(output_dir: str)¶ Save model structure in png.
- Parameters
output_dir – path to the output dir.
-
abstract
postprocess
(inputs: Dict[str, tensorflow.Tensor], outputs: Dict[str, tensorflow.Tensor]) → Tuple[tensorflow.Tensor, Dict]¶ Return a dict used for saving inputs and outputs.
- Parameters
inputs – dict of model inputs
outputs – dict of model outputs
- Returns
tuple, indices and a dict. In the dict, each value is (tensor, normalize, on_label), where - normalize = True if the tensor need to be normalized to [0, 1] - on_label = True if the tensor depends on label
-
deepreg.model.network.
dict_without
(d: dict, key) → dict¶ Return a copy of the given dict without a certain key.
- Parameters
d – dict to be copied.
key – key to be removed.
- Returns
the copy without a key