question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to pass in memory_mask

See original GitHub issue

Hi Phil,

Can we have the option to pass in memory_mask, just like in Official Pytorch Transformers?

Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
lucidrainscommented, Sep 3, 2021

ok, i’ve deployed it in 0.17.10, let me know if that works for you!

import torch
from x_transformers import XTransformer

model = XTransformer(
    dim = 512,
    enc_num_tokens = 256,
    enc_depth = 1,
    enc_heads = 8,
    enc_max_seq_len = 1024,
    dec_num_tokens = 256,
    dec_depth = 1,
    dec_heads = 8,
    dec_max_seq_len = 1024
)

src = torch.randint(0, 256, (1, 1024))
src_mask = torch.ones_like(src).bool()
tgt = torch.randint(0, 256, (1, 1024))
tgt_mask = torch.ones_like(tgt).bool()

attn_mask = ~torch.eye(1024).bool()

loss = model(src, tgt, src_mask = src_mask, tgt_mask = tgt_mask, src_attn_mask = attn_mask) # (1, 1024, 512)
loss.backward()
2reactions
tumbleintoyourheartcommented, Sep 4, 2021

I did some quick tests and it gave instant better results with proper masking thanks to the new feature.

Thanks for your quick responses, it’s very nice of you to even write down some sample codes for me. Really appreciated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

In Loving Memory Mask - Etsy
Browse a wide selection of in loving memory mask and face coverings available in various fabrics and configurations, ...
Read more >
Amazon.com: Sponge Anti-Fog Nose Bridge Pads Seal Nose ...
Sponge Anti-Fog Nose Bridge Pads Seal Nose Cushion Memory Foam Nose Pads Self-Adhesive Protection Strip Nose Pad for Mask 50 PCS Black ;...
Read more >
Change CPU Identification Mask Settings - VMware Docs
Right-click a virtual machine in the inventory and select Edit Settings. On the Virtual Hardware tab, expand CPU and select an NX/XD option...
Read more >
Do Foam CPAP Masks Work?
Now, there is another option. Memory Foam CPAP masks have become a very interesting alternative to the silicone options. There are pros and ......
Read more >
MASK: Redesigning the GPU Memory Hierarchy to Support ...
We propose MASK, a new GPU framework that mitigates address translation overheads in the presence of multi-address-space concurrency. MASK consists of three ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found