k1lib.knn module¶
Some nice utils to complement torch.nn
. This is exposed automatically
with:
from k1lib.imports import *
knn.Lambda # exposed
-
class
k1lib.knn.
Lambda
(f: Callable[[Any], Any])[source]¶ Bases:
torch.nn.modules.module.Module
-
__init__
(f: Callable[[Any], Any])[source]¶ Creates a simple module with a specified
forward()
function.
-
forward
(x)[source]¶ Defines 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
k1lib.knn.
Identity
[source]¶ Bases:
k1lib.knn.Lambda
Creates a module that returns the input in
forward()