Coder Social home page Coder Social logo

cyril9227 / keras_attentivenormalization Goto Github PK

View Code? Open in Web Editor NEW
29.0 5.0 5.0 245 KB

Unofficial Keras implementation of the paper Attentive Normalization.

License: MIT License

Python 43.83% Jupyter Notebook 56.17%
deep-learning batch-normalization attention-mechanism keras keras-tensorflow

keras_attentivenormalization's People

Contributors

cyril9227 avatar overlordgolddragon 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

Watchers

 avatar  avatar  avatar  avatar  avatar

keras_attentivenormalization's Issues

3D AN?

It appears this implementation only supports 4D inputs - though Conv1D takes and outputs 3D tensors; I found that making below changes enables AN to work for 3D tensors without errors:

GlobalAveragePooling2D() --> GlobalAveragePooling1D()
gamma_readjust[:, None, None, :] --> gamma_readjust[:, None, :]
beta_readjust[:, None, None, :] --> beta_readjust[:, None, :] 

I'm unsure, however, whether this is a correct implementation consistent with the paper - can you confirm? Thanks

Can not run test script

Hi There,

I have tried to run the test script several times but not running.


TypeError Traceback (most recent call last)
in
1 inp = Input((64, 64, 3))
2 x = Dense(20, activation="relu")(inp)
----> 3 x = AttentiveNormalization(n_mixture=5, momentum=0.99, epsilon=0.001, axis=-1)(x)

TypeError: list indices must be integers or slices, not ListWrapper

My configurations:
python 3.6
TensorFlow-GPU 2.0.0
Keras 2.2.4

TypeError: Exception encountered when calling layer "attentive_normalization" (type AttentiveNormalization)

TypeError Traceback (most recent call last)
in
12 x = Dense(20, activation="relu")(inp)
13 print(x.shape)
---> 14 x = AttentiveNormalization(n_mixture=5, momentum=0.99, epsilon=0.001, axis=-1)(x)
15 x = GlobalAveragePooling2D()(x)
16 pred = Dense(1, activation='sigmoid')(x)

1 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/autograph/impl/api.py in wrapper(*args, **kwargs)
690 except Exception as e: # pylint:disable=broad-except
691 if hasattr(e, 'ag_error_metadata'):
--> 692 raise e.ag_error_metadata.to_exception(e)
693 else:
694 raise

TypeError: Exception encountered when calling layer "attentive_normalization" (type AttentiveNormalization).

in user code:

File "/content/drive/MyDrive/fall22sem/AN/AttentiveNormalization.py", line 57, in call  *
    out_BN = super(AttentiveNormalization, self).call(input) # rescale input, N x H x W x C
File "/usr/local/lib/python3.7/dist-packages/keras/layers/normalization/batch_normalization.py", line 784, in call  **
    reduction_axes = [i for i in range(ndims) if i not in self.axis]
File "/usr/local/lib/python3.7/dist-packages/keras/layers/normalization/batch_normalization.py", line 784, in <listcomp>
    reduction_axes = [i for i in range(ndims) if i not in self.axis]

TypeError: argument of type 'int' is not iterable

Call arguments received:
โ€ข input=tf.Tensor(shape=(None, 64, 64, 20), dtype=float32)

Question about the weight of each channel

image
First, thanks for sharing this work.But I have some confusion, as what I show in this pic. Do you mean that for each batch(like N_0), for each channel in this batch.the weight(the dimension is K) is the same?Because I also notice that the shape of the output of the sigmoid is the (N*K).
Thanks for your answer.

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.