> ## Documentation Index
> Fetch the complete documentation index at: https://docs.thrindex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# E0004 — DimensionMismatch (sim)

> Two consecutive layers in the artifact have incompatible input/output dimensions.

<Warning>E0004: layer dimension mismatch</Warning>

## What happened

Layer `N` in the artifact declares `expected` input features, but the preceding layer `N-1` produces `got` output features. The two cannot be connected.

## Why

The artifact is corrupt. This error should not occur if the artifact was produced by `thx.compile()`, because the compiler's validate pass catches dimension mismatches at compile time with [E0106](/errors/E0106). If you see E0004 at run time, the artifact was likely modified after compilation.

## How to fix

1. **Recompile the model** from scratch: `thx.compile(model, "model.thx")`.
2. Verify artifact integrity before reporting a bug: `thrindex doctor --check model.thx`.
3. If `doctor --check` reports a CRC32 mismatch, you will see [E0009](/errors/E0009) as well — the artifact was tampered with.

## Example

```
E0004: layer dimension mismatch at layer 2
Why: layer 2 expects 512 input features but receives 256 from layer 1.
Fix: recompile the model — the artifact may be corrupt.
Docs: https://docs.thrindex.com/errors/E0004
```

## Related

* [E0106](/errors/E0106) — the compiler-time version of this error
* [E0009](/errors/E0009) — CRC32 mismatch indicating tampering
