Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prep_batch_ranges() causes the remainer to be dropped #17

Open
sgsutcliffe opened this issue Dec 3, 2024 · 0 comments
Open

prep_batch_ranges() causes the remainer to be dropped #17

sgsutcliffe opened this issue Dec 3, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@sgsutcliffe
Copy link

Problem

In the matrix_splitter class the function for dividing up a matrix into batches prep_batch_ranges does not update the ranges if their is a remainer, thus droping the samples during performing batches.

Proposed Solution

Add the num_lines to last batch range so that all samples are included.
e.g.

def prep_batch_ranges(num_lines, batch_size):
    num_batches = int(num_lines / batch_size)
    rem = batch_size % num_batches
    ranges = []
    for i in range(0,num_batches):
        ranges.append((i*batch_size,i*batch_size+batch_size))
    if rem != 0:
        r = ranges[-1]
        r = list(r)
        r[1] = num_lines
        ranges[-1] = r
    return ranges

print(prep_batch_ranges(32,5))

Note

This will impact the tests that are being created in the PR #7

@sgsutcliffe sgsutcliffe added the bug Something isn't working label Dec 3, 2024
@sgsutcliffe sgsutcliffe self-assigned this Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant