dacapo.experiments.architectures.architecture ============================================= .. py:module:: dacapo.experiments.architectures.architecture Classes ------- .. autoapisummary:: dacapo.experiments.architectures.architecture.Architecture Module Contents --------------- .. py:class:: Architecture(*args, **kwargs) An abstract base class for defining the architecture of a neural network model. It is inherited from PyTorch's Module and built-in class `ABC` (Abstract Base Classes). Other classes can inherit this class to define their own specific variations of architecture. It requires to implement several property methods, and also includes additional methods related to the architecture design. .. attribute:: input_shape The spatial input shape for the neural network architecture. :type: Coordinate .. attribute:: eval_shape_increase The amount to increase the input shape during prediction. :type: Coordinate .. attribute:: num_in_channels The number of input channels required by the architecture. :type: int .. attribute:: num_out_channels The number of output channels provided by the architecture. :type: int .. method:: dims Returns the number of dimensions of the input shape. .. method:: scale Scales the input voxel size as required by the architecture. .. note:: The class is abstract and requires to implement the abstract methods. .. py:property:: input_shape :type: funlib.geometry.Coordinate :abstractmethod: Abstract method to define the spatial input shape for the neural network architecture. The shape should not account for the channels and batch dimensions. :returns: The spatial input shape. :rtype: Coordinate :raises NotImplementedError: If the method is not implemented in the derived class. .. rubric:: Examples >>> input_shape = Coordinate((128, 128, 128)) >>> model = MyModel(input_shape) .. note:: The method should be implemented in the derived class. .. py:property:: eval_shape_increase :type: funlib.geometry.Coordinate Provides information about how much to increase the input shape during prediction. :returns: An instance representing the amount to increase in each dimension of the input shape. :rtype: Coordinate :raises NotImplementedError: If the method is not implemented in the derived class. .. rubric:: Examples >>> eval_shape_increase = Coordinate((0, 0, 0)) >>> model = MyModel(input_shape, eval_shape_increase) .. note:: The method is optional and can be overridden in the derived class. .. py:property:: num_in_channels :type: int :abstractmethod: Abstract method to return number of input channels required by the architecture. :returns: Required number of input channels. :rtype: int :raises NotImplementedError: If the method is not implemented in the derived class. .. rubric:: Examples >>> num_in_channels = 1 >>> model = MyModel(input_shape, num_in_channels) .. note:: The method should be implemented in the derived class. .. py:property:: num_out_channels :type: int :abstractmethod: Abstract method to return the number of output channels provided by the architecture. :returns: Number of output channels. :rtype: int :raises NotImplementedError: If the method is not implemented in the derived class. .. rubric:: Examples >>> num_out_channels = 1 >>> model = MyModel(input_shape, num_out_channels) .. note:: The method should be implemented in the derived class. .. py:property:: dims :type: int Returns the number of dimensions of the input shape. :returns: The number of dimensions. :rtype: int :raises NotImplementedError: If the method is not implemented in the derived class. .. rubric:: Examples >>> input_shape = Coordinate((128, 128, 128)) >>> model = MyModel(input_shape) >>> model.dims 3 .. note:: The method is optional and can be overridden in the derived class. .. py:method:: scale(input_voxel_size: funlib.geometry.Coordinate) -> funlib.geometry.Coordinate Method to scale the input voxel size as required by the architecture. :param input_voxel_size: The original size of the input voxel. :type input_voxel_size: Coordinate :returns: The scaled voxel size. :rtype: Coordinate :raises NotImplementedError: If the method is not implemented in the derived class. .. rubric:: Examples >>> input_voxel_size = Coordinate((1, 1, 1)) >>> model = MyModel(input_shape) >>> model.scale(input_voxel_size) Coordinate((1, 1, 1)) .. note:: The method is optional and can be overridden in the derived class.