Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with RationalHat layer, local variable 'LVinit' referenced before assignment #14

Open
RandomAnass opened this issue Mar 29, 2022 · 0 comments

Comments

@RandomAnass
Copy link

When I use the layer "RationalHat", I get the following error:

UnboundLocalError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_33568/2646110522.py in
65 rho = tf.keras.Sequential([tf.keras.layers.Dense(1, activation="sigmoid")])
66 model = None
---> 67 model = PerslayModel(name="PersLay", diagdim=2, perslay_parameters=perslay_parameters, rho=rho)
68 model.compile(loss='binary_crossentropy',optimizer=optimizer,metrics=['accuracy'])
69 print(optimizer,perm_op,pweight,layer)

~\anaconda3\envs\downgrade\lib\site-packages\perslay\perslay.py in init(self, name, diagdim, perslay_parameters, rho)
159 LMinit, LRinit = plp["lmean_init"], plp["lr_init"]
160 LMiv = LMinit if not callable(LMinit) else LMinit([self.diagdim, plp["lnum"]])
--> 161 LRiv = LRinit if not callable(LRinit) else LVinit([1])
162 LM = tf.Variable(name=Lname+"-M", initial_value=LMiv, trainable=Ltrain)
163 LR = tf.Variable(name=Lname+"-R", initial_value=LRiv, trainable=Ltrain)

UnboundLocalError: local variable 'LVinit' referenced before assignment

When I checked the perslay.py file, I found :

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])
    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])

Where LVinit is used before being defined, unlike the other layers where its defined at the beginning (after elif).

I dont know if I am not using the layer correctly (for example if I had to define an other layer before it). But I tried the same code with all the other layers (except the image layer) and it worked without an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant