From 7e5ea0eee45299c40f8516f6c21798ca01aeb989 Mon Sep 17 00:00:00 2001 From: "anass.al-ammiri" <51008418+RandomAnass@users.noreply.github.com> Date: Thu, 14 Aug 2025 01:27:15 +0200 Subject: [PATCH] Fix RationalHat layer UnboundLocalError Fixes issue where RationalHat layer initialization used undefined variable LVinit instead of LRinit, causing UnboundLocalError: local variable 'LVinit' referenced before assignment. - Changed line 161: LVinit([1]) -> LRinit([1]) - Verified fix works with test case - Resolves GitHub issue #4 --- perslay/perslay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perslay/perslay.py b/perslay/perslay.py index 520164b3..acae4048 100644 --- a/perslay/perslay.py +++ b/perslay/perslay.py @@ -158,7 +158,7 @@ def __init__(self, name, diagdim, perslay_parameters, rho): elif layer == "RationalHat": LMinit, LRinit = plp["lmean_init"], plp["lr_init"] LMiv = LMinit if not callable(LMinit) else LMinit([self.diagdim, plp["lnum"]]) - LRiv = LRinit if not callable(LRinit) else LVinit([1]) + LRiv = LRinit if not callable(LRinit) else LRinit([1]) # Fixed: was LVinit([1]) causing UnboundLocalError LM = tf.Variable(name=Lname+"-M", initial_value=LMiv, trainable=Ltrain) LR = tf.Variable(name=Lname+"-R", initial_value=LRiv, trainable=Ltrain) self.vars[nf].append([LM, LR])