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

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants