Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Add layer wrapper type for Collection types #1021

Open
dan-zheng opened this issue Jun 24, 2020 · 0 comments
Open

Add layer wrapper type for Collection types #1021

dan-zheng opened this issue Jun 24, 2020 · 0 comments
Assignees

Comments

@dan-zheng
Copy link
Member

Add a SequentialComposition<Base> layer wrapper type.

SequentialComposition is a Layer that wraps a collection, applying each element in sequence to an input to produce an output. The callAsFunction method calls differentiableReduce, with the input as the initial value.

This allows collections of Layers like [Dense<Float>] to be treated as a Layer.

Original idea and work by @dabrahams.
Work-in-progress implementation: currently blocked by Collection.differentiableReduce(_:_:).


An alternative idea is to directly conform Array to Layer: #708.

But this hardcodes a particular Array: Layer conformance, when there may be multiple ways to interpret an Array as a Layer. A generic "SequentialComposition<Base>" layer wrapper type is more flexible and explicit about the Layer behavior.

Full rationale by @dabrahams.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant