Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

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

Open

Description

@dan-zheng

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>>>>

Activity

  1. andrewasche commented on May 7, 2020

    @andrewasche

    Can I do this?

  2. dan-zheng commented on May 7, 2020

    @dan-zheng
    MemberAuthor

    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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions