Giter Club home page Giter Club logo

uzaymacar / attention-mechanisms Goto Github PK

View Code? Open in Web Editor NEW
336.0 11.0 84.0 538 KB

Implementations for a family of attention mechanisms, suitable for all kinds of natural language processing tasks and compatible with TensorFlow 2.0 and Keras.

License: MIT License

Python 100.00%
attention-mechanism natural-language-processing natural-language-understanding recurrent-neural-networks sequence-to-sequence-models many-to-many many-to-one sentiment-classification text-generation language-model

attention-mechanisms's Issues

Question to implement

First, Thank you for your work

By following your description, I'm trying to implement the attention layers each with tf 2.1.

I have a question that does the line 221 requires to be add a "squeeze" the inputs ?
attention_score = RepeatVector(source_hidden_states.shape[1])(tf.squeeze(attention_score))
because if i understood the full code correctly, the h_t is already expanded_dim and its attention score is (B, 1, H) before getting in the Repeatvector. However, when i feeding the (B, 1, H) to repeat vector, it rise an error as [repeat_vector is incompatible with the layer: expected ndim=2, found ndim=3.]

Thank you

attention_score = RepeatVector(source_hidden_states.shape[1])(attention_score) # (B, S*, H)

Bug Report

Dear sir or madam:

Thanks for your time. Recently I have been studying your codes of attention-mechanisms and felt it is very beneficial for me. However, a bug occurs when I run document_classification.py, which throws an error that: 'Dimension' object does not support indexing. It seems that some bugs exist in Class Attention(Layer). The Parameter config was set to 1 and 2 respectively but the same bug appears, and it points out that the codes "self.input_sequence_length, self.hidden_dim = input_shape[0][1], input_shape[0][2]" (line 103, layers.py) lead to the problem. Could you please help me to fix this bug. I'd appreciate it if you are kind to help me.

Best wishes,
Jie Yang
1
2

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.