# InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [5,10] rhs shape= [10,10]

- **ID:** `tensorflow/invalid-argument-optimizer-slot-variable-mismatch`
- **Domain:** tensorflow
- **Category:** config_error
- **Error Code:** `IAS`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

Optimizer slot variable shape mismatch, often due to loading a checkpoint from a model with different architecture or incompatible optimizer state.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| tensorflow 2.12.0 | active | — | — |
| tensorflow 2.13.0 | active | — | — |

## Workarounds

1. **Load only the model weights, not optimizer state, by excluding optimizer variables when restoring:
model.load_weights('checkpoint.ckpt', by_name=True, skip_mismatch=True)
# Or use: model.load_weights('checkpoint.ckpt', skip_mismatch=True)** (85% success)
   ```
   Load only the model weights, not optimizer state, by excluding optimizer variables when restoring:
model.load_weights('checkpoint.ckpt', by_name=True, skip_mismatch=True)
# Or use: model.load_weights('checkpoint.ckpt', skip_mismatch=True)
   ```
2. **Reinitialize the optimizer and train from scratch, or use a checkpoint that matches the current model architecture exactly.** (90% success)
   ```
   Reinitialize the optimizer and train from scratch, or use a checkpoint that matches the current model architecture exactly.
   ```

## Dead Ends

- **** — Checkpoint files are binary; manual modification corrupts them. (80% fail)
- **** — This flag only controls device placement, not tensor shapes. (95% fail)
