Repository: patrick-kidger/equinox
Pull request #947 (2025-02-07 18:53:31)

Added external repos in Examples
Based on the discussion on https://github.com/patrick-kidger/equinox/issues/936 - I seperated the notebooks from the external repos, and added some projects from the awesome list mentionned - is this how you saw things ?

patrick-kidger: Ah, awesome!
So my guess is that having the list of these projects live in the sidebar is going to get quite unwieldy as we add to this list. (And there's quite a few other external projects I know of that I'd like to add here!)

For that reason I'm thinking it might be easier to put them on a single page, and then have that page somewhere prominent in the sidebar. Maybe something like:
```
# mkdocs.yml

nav:
    ...
    - Examples:
        - Introductory: 
            ...
        - Advanced:
            ...
        - Features:
            ...
        - Awesome list: 'examples/awesome-list.md'

# awesome-list.md

Details here!
```

WDYT?
TugdualKerjan: definetly agree - changes made with a short description to make it a little bit clearer what each project points to etc !

tell me if anything needs changing on my part 👍 

Patch:
diff --git a/equinox/nn/_linear.py b/equinox/nn/_linear.py
index 4c8655d..8b3fe01 100644
--- a/equinox/nn/_linear.py
+++ b/equinox/nn/_linear.py
@@ -52,7 +52,10 @@ class Linear(Module, strict=True):
         wkey, bkey = jrandom.split(key, 2)
         in_features_ = 1 if in_features == "scalar" else in_features
         out_features_ = 1 if out_features == "scalar" else out_features
-        lim = 1 / math.sqrt(in_features_)
+        if in_features_ == 0:
+            lim = 1.0
+        else:
+            lim = 1 / math.sqrt(in_features_)
         wshape = (out_features_, in_features_)
         self.weight = default_init(wkey, wshape, dtype, lim)
         bshape = (out_features_,)
diff --git a/examples/awesome-list.md b/examples/awesome-list.md
new file mode 100644
index 0000000..5440340
--- /dev/null
+++ b/examples/awesome-list.md
@@ -0,0 +1,32 @@
+# Awesome List
+
+A curated list of external projects from the community that leverage the Equinox framework to build models using JAX.
+
+Feel free to create a PR to add your own projects so that the community may benefit from as many examples as possible !
+## Advanced (External Repos)
+- **Mistral 7B**: [GitHub](https://github.com/AakashKumarNain/mistral_jax)
+    - Implementation of the Mistral 7B model.
+- **PaLM**: [GitHub](https://github.com/lucidrains/PaLM-jax)
+    - Implementation of the Pathways Language Model (PaLM).
+- **HiFiGAN**: [GitHub](https://github.com/TugdualKerjan/hifigan-jax)
+    - HiFiGAN vocoder using two discriminators to map mel-spectrograms to audio.
+- **nanoGPT**: [GitHub](https://github.com/TugdualKerjan/nanoEQXGPT)
+    - Port of nanoGPT, a minimalist implementation of a Generative Pre-trained Transformer.
+- **VQVAE**: [GitHub](https://github.com/TugdualKerjan/audio-vae-jax)
+    - Implementation of a VQ-VAE (Vector Quantized Variational Autoencoder) for audio generation.
+
+## Projects Based on Equinox
+- **Levanter**: [GitHub](https://github.com/stanford-crfm/levanter)
+    - Deep learning library for training large language models.
+- **Eqxvision**: [GitHub](https://github.com/paganpasta/eqxvision)
+    - Computer vision library built on Equinox, inspired by torchvision.
+- **Haliax**: [GitHub](https://github.com/stanford-crfm/haliax)
+    - Library for distributed multi-dimensional arrays, designed for large-scale machine learning.
+- **Diffrax**: [GitHub](https://github.com/patrick-kidger/diffrax)
+    - Library for numerical differential equation solvers.
+- **Optimistix**: [GitHub](https://github.com/patrick-kidger/optimistix)
+    - Library for nonlinear optimization.
+- **FlowJAX**: [GitHub](https://github.com/danielward27/flowjax?tab=readme-ov-file)
+    - Library for normalizing flows and probabilistic machine learning.
+- **Lineax**: [GitHub](https://github.com/patrick-kidger/lineax)
+    - Library for linear solvers, linear least squares, and eigenvalue solvers.
\ No newline at end of file
diff --git a/examples/mistral_7b.md b/examples/mistral_7b.md
deleted file mode 100644
index 72df0e7..0000000
--- a/examples/mistral_7b.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Mistral 7B
-
-An Equinox implementation of [Mistral 7B](https://github.com/mistralai/mistral-src/) model is available in the [AakashKumarNain/mistral_jax](https://github.com/AakashKumarNain/mistral_jax) repository!
diff --git a/mkdocs.yml b/mkdocs.yml
index 574bbf4..5deb655 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -103,19 +103,19 @@ nav:
         - Introductory:
             - CNN on MNIST: 'examples/mnist.ipynb'
             - Train RNN: 'examples/train_rnn.ipynb'
-        - Advanced:
-            - Generative score-based diffusion: 'examples/score_based_diffusion.ipynb'
-            - BERT language model: 'examples/bert.ipynb'
-            - U-Net implementation: 'examples/unet.ipynb'
-            - Vision transformer: 'examples/vision_transformer.ipynb'
-            - Image GAN: 'examples/deep_convolutional_gan.ipynb'
-            - Mistral 7B: 'examples/mistral_7b.md'
         - Features:
             - Freezing parameters: 'examples/frozen_layer.ipynb'
             - Compatibility with init-apply libraries: 'examples/init_apply.ipynb'
             - Stateful operations (e.g. BatchNorm): 'examples/stateful.ipynb'
             - Autoparallelism (e.g. multi-GPU): 'examples/parallelism.ipynb'
             - Serialisation (with hyperparameters): 'examples/serialisation.ipynb'
+        - Advanced (Notebooks):
+            - Generative score-based diffusion: 'examples/score_based_diffusion.ipynb'
+            - BERT language model: 'examples/bert.ipynb'
+            - U-Net implementation: 'examples/unet.ipynb'
+            - Vision transformer: 'examples/vision_transformer.ipynb'
+            - Image GAN: 'examples/deep_convolutional_gan.ipynb'
+        - Awesome list: 'awesome-list.md'
     - Basic API:
         - Modules:
             - 'api/module/module.md'


Test patch:
diff --git a/tests/test_nn.py b/tests/test_nn.py
index d20ac9b..aeeee0a 100644
--- a/tests/test_nn.py
+++ b/tests/test_nn.py
@@ -22,6 +22,16 @@ def test_custom_init():
 
 
 def test_linear(getkey):
+    # Zero input shape
+    linear = eqx.nn.Linear(0, 4, key=getkey())
+    x = jrandom.normal(getkey(), (0,))
+    assert linear(x).shape == (4,)
+
+    # Zero output shape
+    linear = eqx.nn.Linear(4, 0, key=getkey())
+    x = jrandom.normal(getkey(), (4,))
+    assert linear(x).shape == (0,)
+
     # Positional arguments
     linear = eqx.nn.Linear(3, 4, key=getkey())
     x = jrandom.normal(getkey(), (3,))