Coder Social home page Coder Social logo

ducha-aiki / lsuv-keras Goto Github PK

View Code? Open in Web Editor NEW
66.0 8.0 22.0 10 KB

Simple implementation of the LSUV initialization in keras

License: BSD 2-Clause "Simplified" License

Python 100.00%
keras lsuv lsuv-initialization convolutional-neural-networks convolutional-networks deeplearning initialization

lsuv-keras's Introduction

Layer-sequential unit-variance (LSUV) initialization for Keras

This is sample code for LSUV and initializations, implemented in python script within Keras framework.

Usage:

from lsuv_init import LSUVinit
...
batch_size = 32
model = LSUVinit(model, train_imgs[:batch_size,:,:,:])

LSUV initialization is described in:

Mishkin, D. and Matas, J.,(2015). All you need is a good init. ICLR 2016 arXiv:1511.06422.

Original Caffe implementation https://github.com/ducha-aiki/LSUVinit

Torch re-implementation https://github.com/yobibyte/torch-lsuv

PyTorch implementation https://github.com/ducha-aiki/LSUV-pytorch

New! Thinc re-implementation LSUV-thinc

lsuv-keras's People

Contributors

alexander-rakhlin avatar ducha-aiki avatar emrul avatar iezepov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lsuv-keras's Issues

Initialization failure

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

Runtime Error in TensorFlow 2.4.1

If I run your code, the following error arises:

RuntimeError: The layer has never been called and thus has no defined input.

It is due to model.get_input_at(0) in def get_activations(model, layer, X_batch):, but I can not manage how to fix it...

Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.