A module containing commonly-used functionality to implement architectures.
Package | timm |
No package docstring; 4/5 functions, 2/2 classes, 2/3 modules documented |
From __init__.py
:
Class |
|
A condition that checks if a state dict has the given keys. |
Function | get |
Returns the maximum index i such that key_pattern.format(str(i)) is in state . |
Function | get |
This will detect the upscale factor and number of features of a pixelshuffle module in the state dict. |
Function | get |
Returns a scale and number of output channels such that scale**2 * out_nc = x . |
Function | get |
Returns the length of a sequence in the state dict. |
Function | store |
Stores the hyperparameters of a class in a hyperparameters attribute. |
Returns the maximum index i
such that key_pattern.format(str(i))
is in state
.
If no such key is in state, then -1
is returned.
- Example:
- get_first_seq_index(state, "body.{}.weight") -> -1 get_first_seq_index(state, "body.{}.weight") -> 3
Returns the length of a sequence in the state dict.
The length is detected by finding the maximum index i
such that
{seq_key}.{i}.{suffix}
is in state
for some suffix.
- Example:
- get_seq_len(state, "body") -> 5
Returns a scale and number of output channels such that scale**2 * out_nc = x
.
This is commonly used for pixelshuffel layers.
Mapping[ str, object]
, upsample_key: str
= 'upsample', default_nf: int
= 64) -> tuple[ int, int]
:
(source)
¶
This will detect the upscale factor and number of features of a pixelshuffle module in the state dict.
A pixelshuffle module is a sequence of alternating up convolutions and pixelshuffle.
The class of this module is commonyl called Upsample
.
Examples of such modules can be found in most SISR architectures, such as SwinIR, HAT, RGT, and many more.