Skip to content
Open
Changes from all commits
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
9 changes: 6 additions & 3 deletions jax/_src/nn/initializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,12 @@ def _compute_fans(shape: Sequence[int],
Axes not in in_axis, out_axis, or batch_axis are assumed to constitute the
"receptive field" of a convolution (kernel spatial dimensions).
"""
if len(shape) <= 1:
raise ValueError(f"Can't compute input and output sizes of a {len(shape)}"
"-dimensional weights tensor. Must be at least 2D.")
if in_axis == -2 and len(shape) <= 1:
raise ValueError(
f"Can't compute input and output sizes of a {len(shape)}-dimensional"
" weights tensor with default in-axis. Must be at least 2D or specify"
" in_axis explicitly."
)

if isinstance(in_axis, int):
in_size = shape[in_axis]
Expand Down
Loading