piscis.models.spots#
Attributes#
Classes#
Spot detection model. |
|
Base class for all neural network modules. |
|
Applies an affine linear transformation to the incoming data: \(y = xA^T + b\). |
Functions#
|
Round SpotsModel input size. |
Module Contents#
- piscis.models.spots.BLOCK_ARGS#
- class piscis.models.spots.SpotsModel(in_channels: int = 1, stochastic_depth_prob: float = 0.0, style: bool = True, pooling: str = 'max', kernel_size: Sequence[int] = (3, 3))#
Bases:
torch.nn.ModuleSpot detection model.
- Parameters:
- in_channelsint, optional
Number of input channels. Default is 1.
- stylebool, optional
Whether to use style transfer. Default is True.
- poolingstr, optional
Pooling type applied to labels. Supported types are ‘max’ and ‘sum’. Default is ‘max’.
- stochastic_depth_probfloat, optional
Stochastic depth probability. Default is 0.0.
- kernel_sizeSequence[int], optional
Kernel size or window size of the max pooling operation. Default is (3, 3).
- fpn#
- sigmoid#
- kernel_size = (3, 3)#
- forward(x: torch.Tensor, return_style: bool = False) Tuple[torch.Tensor, torch.Tensor] | Tuple[torch.Tensor, torch.Tensor, torch.Tensor]#
- class piscis.models.spots.Conv2d(in_channels: int, out_channels: int, kernel_size: torch.nn.common_types._size_2_t, stride: torch.nn.common_types._size_2_t = 1, padding: str | torch.nn.common_types._size_2_t = 0, dilation: torch.nn.common_types._size_2_t = 1, groups: int = 1, bias: bool = True, padding_mode: Literal['zeros', 'reflect', 'replicate', 'circular'] = 'zeros', device=None, dtype=None)#
Bases:
torch.nn.Conv2dBase class for all neural network modules.
Your models should also subclass this class.
Modules can also contain other Modules, allowing them to be nested in a tree structure. You can assign the submodules as regular attributes:
import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self) -> None: super().__init__() self.conv1 = nn.Conv2d(1, 20, 5) self.conv2 = nn.Conv2d(20, 20, 5) def forward(self, x): x = F.relu(self.conv1(x)) return F.relu(self.conv2(x))
Submodules assigned in this way will be registered, and will also have their parameters converted when you call
to(), etc.Note
As per the example above, an
__init__()call to the parent class must be made before assignment on the child.- Variables:
training (bool) – Boolean represents whether this module is in training or evaluation mode.
- class piscis.models.spots.Linear(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None)#
Bases:
torch.nn.LinearApplies an affine linear transformation to the incoming data: \(y = xA^T + b\).
This module supports TensorFloat32.
On certain ROCm devices, when using float16 inputs this module will use different precision for backward.
- Args:
in_features: size of each input sample out_features: size of each output sample bias: If set to
False, the layer will not learn an additive bias.Default:
True- Shape:
Input: \((*, H_\text{in})\) where \(*\) means any number of dimensions including none and \(H_\text{in} = \text{in\_features}\).
Output: \((*, H_\text{out})\) where all but the last dimension are the same shape as the input and \(H_\text{out} = \text{out\_features}\).
- Attributes:
- weight: the learnable weights of the module of shape
\((\text{out\_features}, \text{in\_features})\). The values are initialized from \(\mathcal{U}(-\sqrt{k}, \sqrt{k})\), where \(k = \frac{1}{\text{in\_features}}\)
- bias: the learnable bias of the module of shape \((\text{out\_features})\).
If
biasisTrue, the values are initialized from \(\mathcal{U}(-\sqrt{k}, \sqrt{k})\) where \(k = \frac{1}{\text{in\_features}}\)
Examples:
>>> m = nn.Linear(20, 30) >>> input = torch.randn(128, 20) >>> output = m(input) >>> print(output.size()) torch.Size([128, 30])