Skip to content

[Feature Request] Build Sequential without specifying keys #1140

Open
@vmoens

Description

Motivation

Long chains of modules can be confusing, and keeping track of all intermediate values can lead to some confusion.
It'd be nice to be able to build layers without specifying in/out_keys and have them bound to each other authomatically.
Keys that are not specified will be generated automatically and discarded after completion.

Solution

Example:

mod = Seq(
   Mod(lambda x: x+1, in_keys=["x"]), # we always need an in_keys at the beginning, out_keys is figured out automatically
   Mod(lambda x: 2*x), # in_keys and out_keys are lazily set - the previous output will be used as in_keys
   Mod(lambda x: (x, x.sqrt())), # This should also work: 2 out_keys will automatically be set
   Mod(lambda x, y, z: x + y + z), # This will raise an exception as we are waiting for 3 values but the previous module only had 2 outputs
)

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions