From 71a2e74eff46b47692d5c2fbac8159924b8eba4f Mon Sep 17 00:00:00 2001 From: Jensun Ravichandran Date: Mon, 4 Apr 2022 20:55:03 +0200 Subject: [PATCH] feat: add `RandomLinearTransformInitializer` --- prototorch/core/initializers.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/prototorch/core/initializers.py b/prototorch/core/initializers.py index 79101f4..d6ae098 100644 --- a/prototorch/core/initializers.py +++ b/prototorch/core/initializers.py @@ -465,7 +465,15 @@ class OnesLinearTransformInitializer(AbstractLinearTransformInitializer): return self.generate_end_hook(weights) -class EyeTransformInitializer(AbstractLinearTransformInitializer): +class RandomLinearTransformInitializer(AbstractLinearTransformInitializer): + """Initialize a matrix with random values.""" + + def generate(self, in_dim: int, out_dim: int): + weights = torch.rand(in_dim, out_dim) + return self.generate_end_hook(weights) + + +class EyeLinearTransformInitializer(AbstractLinearTransformInitializer): """Initialize a matrix with the largest possible identity matrix.""" def generate(self, in_dim: int, out_dim: int): @@ -539,8 +547,9 @@ RRI = RandomReasoningsInitializer ZRI = ZerosReasoningsInitializer # Aliases - Transforms -Eye = EyeTransformInitializer +ELTI = Eye = EyeLinearTransformInitializer OLTI = OnesLinearTransformInitializer +RLTI = RandomLinearTransformInitializer ZLTI = ZerosLinearTransformInitializer PCALTI = PCALinearTransformInitializer LLTI = LiteralLinearTransformInitializer