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

More informative structure mismatch error message in Linear layer #92

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions penzai/nn/linear_and_affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,12 @@ class Linear(layer_base.Layer):
def __call__(self, in_array: NamedArray, **_unused_side_inputs) -> NamedArray:
"""Runs the linear operator."""
in_struct = self._input_structure()
dimvars = shapecheck.check_structure(in_array, in_struct)
dimvars = shapecheck.check_structure(in_array, in_struct, error_prefix=f"({self.weights.label[:-8]}) ")
amifalk marked this conversation as resolved.
Show resolved Hide resolved

result = contract(self.in_axis_names, in_array, self.weights.value)

out_struct = self._output_structure()
shapecheck.check_structure(result, out_struct, known_vars=dimvars)
shapecheck.check_structure(result, out_struct, known_vars=dimvars, error_prefix=f"({self.weights.label[:-8]}) ")
return result

@classmethod
Expand Down
Loading