Skip to content

fix: Support zero-size shapes in variance scaling initializers - #683

Open
georgeguimaraes wants to merge 1 commit into
elixir-nx:mainfrom
georgeguimaraes:fix/fans-zero-size-shapes
Open

georgeguimaraes wants to merge 1 commit into
elixir-nx:mainfrom
georgeguimaraes:fix/fans-zero-size-shapes

Conversation

@georgeguimaraes

Copy link
Copy Markdown
Member

Depends on elixir-nx/nx#1885 and elixir-nx/nx#1886 (zero-size tensors in Nx). CI fails until they merge.

compute_fans divided the size of the shape by the fans, so a dimension of 0 divided 0 by 0. For example, the hidden state of an LSTM with a batch of 0 raised ArithmeticError. The receptive field size is now the product of the leading dimensions. The fans of other shapes do not change.

compute_fans got the receptive field size by dividing the size of the shape by the fans. A dimension of 0 then divided 0 by 0, for example for the hidden state of an LSTM with a batch of 0.

The receptive field size is now the product of the dimensions before the last two. A shape of rank 1 has fans of 1, which is the value that the division gave. The fans of other shapes do not change.

This needs zero-size tensors in Nx (elixir-nx/nx#1885).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants