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

[Feature suggestion] UnPack proportionally #227

Open
lkhphuc opened this issue Dec 1, 2022 · 0 comments
Open

[Feature suggestion] UnPack proportionally #227

lkhphuc opened this issue Dec 1, 2022 · 0 comments

Comments

@lkhphuc
Copy link

lkhphuc commented Dec 1, 2022

  1. Try to collect use-cases
    If you don't have access to the input API to use pack but still want to unpack it with einops, you would need to know the size of the output. This is not ideal if you known the proportion that you want to unpack into.
x = MyBigPretrainedLibraryImportModel(size='base')  # base, large, huge 

# Instead of
b, s, c = x.shape  # c is different depending on model size
c_param = c // 2
x_mean, x_logvar = unpack(x, [[c_param], [c_param]], 'b s *')

# Accept this
x_mean, x_logvar = unpack(x, [[0.5], [0.5]], 'b s *')
  1. Integrity - does it interplay well with existing operations and notation in einops?
    pack and unpack currently only accepts int, so accepting float shouldn't break anything.
    Incase of float it will be a bit more job, like ensuring all sum to 1, each proportion will scale up to a proper integer etc.
assert c == 512
x1, x_2, x_3 = unpack(x, [[1/3], [1/3], [1/4], 'b s *')  # Raise error as 1/3 + 1/3 + 1/4 != 1
x1, x_2, x_3 = unpack(x, [[1/3], [1/3], [1/3], 'b s *')  # Raise error as 512 is not divisible by 3
  1. Readability
    The complexity of checking validity of proportion might not worth adding it to the library and should be handled by a few lines of user code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant