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

Add layer wrapper type for Collection types #1021

Open
@dan-zheng

Description

@dan-zheng

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions