Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interface for sequential models #480

Open
mcwitt opened this issue Oct 31, 2020 · 0 comments
Open

Add interface for sequential models #480

mcwitt opened this issue Oct 31, 2020 · 0 comments

Comments

@mcwitt
Copy link
Collaborator

mcwitt commented Oct 31, 2020

Once #477 or similar is merged, we could provide an API similar to pytorch's Sequential using for example a Sequential kind wrapping a type-level list, e.g.

data Sequential (models :: [k]) = Sequential (HList models)

and a HasForward instances like

instance HasForward (Sequential '[]) input where
  type Output (Sequential '[]) input = input
  forward _ input = input

instance
  (HasForward model input, HasForward (Sequential models) (Output model input)) =>
  HasForward (Sequential (model ': models)) input
  where
  type Output (Sequential (model ': models)) input = Output (Sequential models) (Output model input)
  forward (Sequential (model :. models)) input = forward (Sequential models) . forward model $ input

(credit for the idea and sketch implementation goes to @tscholak)

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

No branches or pull requests

1 participant