Code Monkey home page Code Monkey logo

Comments (4)

lucidrains avatar lucidrains commented on June 8, 2024 1

@sentialx if everything in the second segment batch were the ignore index (zero in your case), it would be nan, but because there is [1, 2, 0, 0] you are still ok

from recurrent-memory-transformer-pytorch.

lucidrains avatar lucidrains commented on June 8, 2024

@sentialx hey Eryk! that should be handled if you pad your sequences with the ignore_index, which i have set to -1 but is configurable

https://github.com/lucidrains/recurrent-memory-transformer-pytorch/blob/main/recurrent_memory_transformer_pytorch/recurrent_memory_transformer.py#LL432C13-L432C25

from recurrent-memory-transformer-pytorch.

sentialx avatar sentialx commented on June 8, 2024

@lucidrains Thanks for your response, but what happens if a text has 4 segments and the second text in a batch has 2 segments? This means that the two remaining segments in the second batch slot are just filled with paddings to match the longest text, and there will be no predicted tokens, right?

To visualize this, here we have a tensor of shape (batch_size=2, segments=2, seq_len=5) and items are token ids:

[
  [
    [1, 2, 3, 4, 5]
    [1, 2, 3, 4, 0]
  ],
  [
    [1, 2, 0, 0]
    [0, 0, 0, 0] <- loss should be nan I think?
  ]
]

from recurrent-memory-transformer-pytorch.

sentialx avatar sentialx commented on June 8, 2024

@lucidrains one more question, did you have a chance to compare it with block recurrent?

from recurrent-memory-transformer-pytorch.

Related Issues (19)

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.