1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Iterate over batch size for each batch

Discussão em 'Python' iniciado por Stack, Setembro 12, 2024.

  1. Stack

    Stack Membro Participativo

    Its there a more pythonic way, or built in function in python to do the following:

    def batch(number, batch_size):
    number_left = number
    while number_left:
    if number_left >= batch_size:
    yield batch_size
    number_left -= batch_size
    else:
    yield number_left
    number_left = 0


    batch(21,10) outputs: [10,10,1]

    Continue reading...

Compartilhe esta Página