-
Notifications
You must be signed in to change notification settings - Fork 287
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
Fix type checking (mypy) #130
Comments
I tried a bunch to fix it with stub packages but mainly didn't really get anywhere |
Hmm, when I run
|
Hi guys - just wanted to add that it looks like this might be expected because of mypy limitations (see patrick-kidger/torchtyping#35) Patrick's first suggestion of defining an object with the strings might be the way to go. It could help solidify the naming conventions and avoid potential confusion like using "num_components" vs "components", etc. I tried this in from enum import Enum
class T(Enum):
BATCH = "batch"
D_VOCAB = "d_vocab"
POSITION = "position"
D_MODEL = "d_model"
# Embed & Unembed
class Embed(nn.Module):
...
def forward(
self, tokens: TT[T.BATCH, T.POSITION]
) -> TT[T.BATCH, T.POSITION, T.D_MODEL]:
# If A has shape [a, b] and B has shape [c, d], then A[:, B] has shape [a, c, d]
# B acts as a tensor of indices into the second dimension (so >=0 and <b)
return self.W_E[tokens, :] |
@dkamm great idea! This is a far better approach |
Yeah, that looks great @dkamm, I'd love for you to add that if you're
interested.
…On Mon, 16 Jan 2023 at 10:18, Alan ***@***.***> wrote:
@dkamm <https://github.com/dkamm> great idea! This is a far better
approach
—
Reply to this email directly, view it on GitHub
<#130 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASRPNKLNF33XI3KWMTVTWTLWSUN6TANCNFSM6AAAAAATJU6GPA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Sure! Will send a PR |
Currently mypy type checks are not passing - with a large number of easy to resolve errors.
Resolving these would help make the codebase more robust, and the corresponding checks in
/.github/workflows/checks.yml
can then be enabled (they're commented out).https://github.com/neelnanda-io/TransformerLens/blob/72b9be00c12b5be37baaa16b57e5df5e2aff3aad/.github/workflows/checks.yml#L58
The text was updated successfully, but these errors were encountered: