anomalib.models.components.base.dynamic_module

Dynamic Buffer Module.

Module Contents

Classes

DynamicBufferModule

Torch module that allows loading variables from the state dict even in the case of shape mismatch.

class anomalib.models.components.base.dynamic_module.DynamicBufferModule[source]

Bases: abc.ABC, torch.nn.Module

Torch module that allows loading variables from the state dict even in the case of shape mismatch.

get_tensor_attribute(self, attribute_name: str) torch.Tensor[source]

Get attribute of the tensor given the name.

Parameters

attribute_name (str) – Name of the tensor

Raises

ValueErrorattribute_name is not a torch Tensor

Returns

Tensor attribute

Return type

Tensor

_load_from_state_dict(self, state_dict: dict, prefix: str, *args)[source]

Resizes the local buffers to match those stored in the state dict.

Overrides method from parent class.

Parameters
  • state_dict (dict) – State dictionary containing weights

  • prefix (str) – Prefix of the weight file.

  • *args