lnccbrown / lnccbrown/LANfactory
JAX MLP activation list can be smaller than layer list (index misalignment)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 16
- Forks
- 4
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 8
Description
In jax_mlp.py, `self.layers` is built with one entry per layer, but `self.activation_funs` filters out `"linear"` activations.
https://github.com/lnccbrown/LANfactory/blob/9301939e8fed95ee966bf41fe71bb68bd620d7fd/src/lanfactory/trainers/jax_mlp.py#L97-L101
That means `self.activation_funs` can be shorter than `self.layers`.
Later, forward indexes `self.activation_funs[i]` using the layer index, which can raise `IndexError` or apply the wrong activation when `"linear"` appears before the final layer.
```python
def test_mlp_jax_with_linear_hidden_activation():
model = JaxMLP(
layer_sizes=[10, 10, 1],
activations=["tanh", "linear", "linear"],
train_output_type="logprob",
train=True,
)
rng = jax.random.PRNGKey(0)
test_input = jnp.ones((5, 6))
params = model.init(rng, test_input) # fails with IndexError in old pattern
output = model.apply(params, test_input)
assert output.shape == (5, 1)
```
Observed failure:
`IndexError: tuple index out of range` at jax_mlp.py
Expected:
Activation mapping should stay layer-aligned even when `"linear"` is used in hidden layers.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/lanfactory/trainers/jax_mlp.py at the activation-list construction around lines 97–101, then trace how forward indexes activations by layer. Use the provided test_mlp_jax_with_linear_hidden_activation case with the shown JAXMLP configuration. Done means linear hidden activations remain layer-aligned and the model initializes, applies, and produces output with shape (5, 1).
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100