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

Initialization failure #5

Open
dalinzhangzdl opened this issue Jul 7, 2019 · 2 comments
Open

Initialization failure #5

dalinzhangzdl opened this issue Jul 7, 2019 · 2 comments

Comments

@dalinzhangzdl
Copy link

D:\jupyter notebook\lsuv_init.py in LSUVinit(model, batch, verbose, margin, max_iter)
64 weights_and_biases = layer.get_weights()
65 weights_and_biases[0] /= np.sqrt(variance) / np.sqrt(needed_variance)
---> 66 layer.set_weights(weights_and_biases)
67 weights /= np.sqrt(variance) / np.sqrt(needed_variance)
68 layer.set_weights([weights, biases])

UnboundLocalError: local variable 'weights' referenced before assignment

@shaginhekvs
Copy link

It should be changed to following :

layer.set_weights(weights_and_biases)
weights_and_biases[1] /= np.sqrt(variance) / np.sqrt(needed_variance)
layer.set_weights(weights_and_biases)

but [1] actually has biases of the layer, and according to the paper, we're supposed to just scale the weights not the biases, so why is the code initializing biases as well ?

@andrasmolnar
Copy link

Just remove lines 66 and 67 to make it work again:

            weights /= np.sqrt(variance) / np.sqrt(needed_variance)
            layer.set_weights([weights, biases])

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

3 participants