Skip to content

feat: add 2-head MLP skill generator skeleton with tests#2

Merged
tarikuamisganaw merged 1 commit intoiCog-Labs-Dev:mainfrom
lisan-5:feature/skill-generator-mlp
Apr 23, 2026
Merged

feat: add 2-head MLP skill generator skeleton with tests#2
tarikuamisganaw merged 1 commit intoiCog-Labs-Dev:mainfrom
lisan-5:feature/skill-generator-mlp

Conversation

@lisan-5
Copy link
Copy Markdown
Contributor

@lisan-5 lisan-5 commented Apr 22, 2026

Description

Implements the SubRep 2-head MLP generator skeleton.

This PR adds a new PyTorch SkillGenerator that takes an 8D observation and returns two outputs:

  • payoff head: scalar output (shape (1,) for single input, (N, 1) for batch)
  • motives head: 2D output [Safety, Fuel] (shape (2,) for single input, (N, 2) for batch)

Included in this PR:

  • Shared MLP trunk (Linear -> ReLU -> Linear -> ReLU)
  • Explicit weight initialization (Xavier uniform + zero bias)
  • Input-shape validation with clear errors
  • save(path) and load(path, map_location="cpu") model persistence methods (map_location optional, defaults to CPU)
  • Generator README updates documenting architecture and I/O contract

Checklist

  • Code follows project style guidelines
  • Tests added/updated (tests/test_*.py)
  • README updated (if interface changed)
  • Verified locally (all tests pass)

Testing Notes

Run:

python -m pytest tests/test_generator.py -v 

To see example generator output printed from the save/load test:

python -m pytest tests/test_generator.py -v -s

Optional direct runtime check:

@'
import torch
from generator.skill_generator import SkillGenerator

model = SkillGenerator()
obs = torch.randn(8)
payoff, motives = model(obs)
print("payoff shape:", tuple(payoff.shape))
print("motives shape:", tuple(motives.shape))
print("payoff:", payoff.detach())
print("motives:", motives.detach())
'@ | python -

@tarikuamisganaw tarikuamisganaw merged commit bc4ffd3 into iCog-Labs-Dev:main Apr 23, 2026
1 check passed
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