Comments (3)
QUESTION A
It is either 1 or 2. If you are using copy attention, then it is (1), otherwise, it is (2). You can check here.
QUESTION B
Yes, you can. You just need to update the code snippet as I referenced above.
from neuralcodesum.
Thanks a lot for the fast reply!
I checked and my model has copy_attn set to true, and I was extracting beam_attn, so I was getting the 'copy' attention, right?
I already performed the required modification in order to extract both attentions:
if self.copy_attn:
out = copy_generator.forward(dec_out, attn["copy"], src_map)
out = out.squeeze(1)
# beam x batch_size x tgt_vocab
out = unbottle(out.data)
for b in range(out.size(0)):
for bx in range(out.size(1)):
if blank[bx]:
blank_b = torch.Tensor(blank[bx]).to(code_word_rep)
fill_b = torch.Tensor(fill[bx]).to(code_word_rep)
out[b, bx].index_add_(0, fill_b,
out[b, bx].index_select(0, blank_b))
out[b, bx].index_fill_(0, blank_b, 1e-10)
transformer_attention = unbottle(attn["std"].squeeze(1)) # CHANGE - CONSIDER THIS TRANSFORMER "REGULAR" ATTENTION (?)
beam_attn = unbottle(attn["copy"].squeeze(1)) # CONSIDER THIS COPY ATTENTION (?)
else:
out = generator.forward(dec_out.squeeze(1))
# beam x batch_size x tgt_vocab
out = unbottle(f.softmax(out, dim=1))
# beam x batch_size x tgt_vocab
transformer_attention = None
beam_attn = unbottle(attn["std"].squeeze(1))
I want to know if I can now consider the "std" that I extract as correct "regular" transformer attention and the beam attention (that I was already extracting before) as copy attention, correct?
Thanks in advance.
from neuralcodesum.
According to my understanding, yes, you are right.
from neuralcodesum.
Related Issues (20)
- Problem about the symbol in python data. HOT 2
- Getting the embedding for the sample code HOT 3
- code.original_subtoken file not found HOT 1
- ??md
- Potential Bug iterator Pytorch HOT 1
- RuntimeError: "index_select_out_cuda_impl" not implemented for 'Float While comment generation testing the code HOT 3
- Model is not learning problem HOT 4
- Split decoder HOT 1
- No such file: ../../data/java/test/code.original_subtoken while training a model HOT 3
- Questions about javadoc generation HOT 1
- how to train a model without copy attention? HOT 1
- problem while trying to test the code HOT 2
- Do you have a trained model? HOT 1
- Question about dataset HOT 2
- Project dependencies may have API risk issues
- Model is not learning and is not generating meaningful output HOT 1
- Number of generated samples does not HOT 1
- Couldn't testing after training, error information just like this.... HOT 1
- Question regarding qualitative example from your paper.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neuralcodesum.