Skip to content

Commit

Permalink
Clarify comments in code.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathisgerdes committed Nov 3, 2022
1 parent 062eed3 commit 18befe7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions flax/linen/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,14 +695,16 @@ def __call__(self, inputs: Array) -> Array:
-(y_dim - x_dim) % (2 * x_dim)
for y_dim, x_dim in zip(y.shape[1:-1], scaled_x_dims)
]
# Divide the padding equally between left and right. The choice to put
# "+1" on the left (and not on the right) represents a convention for
# aligning even-sized kernels.
# Divide the padding equally between left and right.
if self.transpose_kernel:
# The choice to put "+1" on the right (and not on the left)
# represents a convention for aligning kernels.
total_pad = [
(size_diff // 2, (size_diff + 1) // 2) for size_diff in size_diffs
]
else:
# This was the convention chosen previously and is kept here for
# backward compatibility.
total_pad = [
((size_diff + 1) // 2, size_diff // 2) for size_diff in size_diffs
]
Expand Down

0 comments on commit 18befe7

Please sign in to comment.