Skip to content
This repository has been archived by the owner on Feb 13, 2025. It is now read-only.

Rewrite long nested Sequential types using Sequential{N} typealiases #492

Open
dan-zheng opened this issue May 6, 2020 · 2 comments
Open
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@dan-zheng
Copy link
Member

Sequential{N} typealiases were added in tensorflow/swift-apis#934:

import TensorFlow
// Before:
typealias Model = Sequential<Dense<Float>, Sequential<Dense<Float>, Dense<Float>>>
// After:
typealias Model = Sequential3<Dense<Float>, Dense<Float>, Dense<Float>>

The tuple-like typealiases are easier to use. Long nested Sequential types should be rewritten to use them:

var module: Sequential<Sequential<Conv2D<Float>, Sequential<Function<Tensor<Float>, Tensor<Float>>, Sequential<Conv2D<Float>, Sequential<BatchNorm<Float>, Sequential<Function<Tensor<Float>, Tensor<Float>>, Sequential<Conv2D<Float>, Sequential<BatchNorm<Float>, Function<Tensor<Float>, Tensor<Float>>>>>>>>>, Sequential<ConvLayer, Sequential<BatchNorm<Float>, Sequential<Function<Tensor<Float>, Tensor<Float>>, ConvLayer>>>>

@dan-zheng dan-zheng added help wanted Extra attention is needed good first issue Good for newcomers labels May 6, 2020
@andrewasche
Copy link

Can I do this?

@dan-zheng
Copy link
Member Author

Sure!

I don't know if tensorflow/swift-apis#934 has propagated to "nightly" (six hourly) toolchains yet, I think it should have.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants