fovi.arch.knnconvnextv2

class fovi.arch.knnconvnextv2.GRN(dim)[source]

Bases: Module

GRN (Global Response Normalization) layer.

Parameters:

dim (int) – Number of input channels.

__init__(dim)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class fovi.arch.knnconvnextv2.LayerNorm(normalized_shape, eps=1e-6, data_format='channels_last')[source]

Bases: Module

LayerNorm that supports two data formats: channels_last (default) or channels_first.

The ordering of the dimensions in the inputs. channels_last corresponds to inputs with shape (batch_size, locations, channels) while channels_first corresponds to inputs with shape (batch_size, channels, locations).

Parameters:
  • normalized_shape (int) – Expected input size from the last dimension.

  • eps (float) – A value added to the denominator for numerical stability. Default: 1e-6

  • data_format (str) – The ordering of the dimensions. Default: “channels_last”

__init__(normalized_shape, eps=1e-6, data_format='channels_last')[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class fovi.arch.knnconvnextv2.Block(dim, coords, drop_path=0., **kwargs)[source]

Bases: Module

ConvNeXtV2 Block.

Parameters:
  • dim (int) – Number of input channels.

  • coords – Input/output coordinates for KNN operations.

  • drop_path (float) – Stochastic depth rate. Default: 0.0

  • **kwargs – Additional keyword arguments.

Returns:

Output tensor with same shape as input.

Return type:

torch.Tensor

__init__(dim, coords, drop_path=0., **kwargs)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class fovi.arch.knnconvnextv2.ConvNeXtV2(in_res, fov, cmf_a, style, auto_match_cart_resources=1, device='cuda', in_chans=3, num_classes=1000, first_stride=4, depths=[3, 3, 9, 3], dims=[96, 192, 384, 768], drop_path_rate=0., head_init_scale=1., **kwargs)[source]

Bases: Module

ConvNeXt V2.

Parameters:
  • in_res (int) – Input resolution.

  • fov (float) – Field of view parameter.

  • cmf_a (float) – CMF parameter.

  • style (str) – Style parameter.

  • auto_match_cart_resources (int) – Auto match cartesian resources. Default: 1

  • device (str) – Device to use. Default: ‘cuda’

  • in_chans (int) – Number of input image channels. Default: 3

  • num_classes (int) – Number of classes for classification head. Default: 1000

  • first_stride (int) – First stride value. Default: 4

  • depths (list) – Number of blocks at each stage. Default: [3, 3, 9, 3]

  • dims (list) – Feature dimension at each stage. Default: [96, 192, 384, 768]

  • drop_path_rate (float) – Stochastic depth rate. Default: 0.

  • head_init_scale (float) – Init scaling value for classifier weights and biases. Default: 1.

  • **kwargs – Additional keyword arguments.

Returns:

Classification logits or features.

Return type:

torch.Tensor

__init__(in_res, fov, cmf_a, style, auto_match_cart_resources=1, device='cuda', in_chans=3, num_classes=1000, first_stride=4, depths=[3, 3, 9, 3], dims=[96, 192, 384, 768], drop_path_rate=0., head_init_scale=1., **kwargs)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward_features(x)[source]
forward(x)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

fovi.arch.knnconvnextv2.knnconvnextv2_atto(**kwargs)[source]

Create a KNN ConvNeXtV2 Atto model.

Parameters:

**kwargs – Additional keyword arguments passed to ConvNeXtV2.

Returns:

The model instance.

Return type:

ConvNeXtV2

fovi.arch.knnconvnextv2.knnconvnextv2_femto(**kwargs)[source]

Create a KNN ConvNeXtV2 Femto model.

Parameters:

**kwargs – Additional keyword arguments passed to ConvNeXtV2.

Returns:

The model instance.

Return type:

ConvNeXtV2

fovi.arch.knnconvnextv2.knnconvnextv2_pico(**kwargs)[source]

Create a KNN ConvNeXtV2 Pico model.

Parameters:

**kwargs – Additional keyword arguments passed to ConvNeXtV2.

Returns:

The model instance.

Return type:

ConvNeXtV2

fovi.arch.knnconvnextv2.knnconvnextv2_nano(**kwargs)[source]

Create a KNN ConvNeXtV2 Nano model.

Parameters:

**kwargs – Additional keyword arguments passed to ConvNeXtV2.

Returns:

The model instance.

Return type:

ConvNeXtV2

fovi.arch.knnconvnextv2.knnconvnextv2_tiny(**kwargs)[source]

Create a KNN ConvNeXtV2 Tiny model.

Parameters:

**kwargs – Additional keyword arguments passed to ConvNeXtV2.

Returns:

The model instance.

Return type:

ConvNeXtV2

fovi.arch.knnconvnextv2.knnconvnextv2_base(**kwargs)[source]

Create a KNN ConvNeXtV2 Base model.

Parameters:

**kwargs – Additional keyword arguments passed to ConvNeXtV2.

Returns:

The model instance.

Return type:

ConvNeXtV2

fovi.arch.knnconvnextv2.knnconvnextv2_large(**kwargs)[source]

Create a KNN ConvNeXtV2 Large model.

Parameters:

**kwargs – Additional keyword arguments passed to ConvNeXtV2.

Returns:

The model instance.

Return type:

ConvNeXtV2

fovi.arch.knnconvnextv2.knnconvnextv2_huge(**kwargs)[source]

Create a KNN ConvNeXtV2 Huge model.

Parameters:

**kwargs – Additional keyword arguments passed to ConvNeXtV2.

Returns:

The model instance.

Return type:

ConvNeXtV2