Sequential
A sequential layer that concatenates the computations of two other layers.
With function builders, a sequential layer can be used to express sequential models in a type safe way.
Example:
let model = Sequential {
Dense<Float, CPU>(inputSize: 32, outputSize: 64)
Relu<Float, CPU>()
Dense<Float, CPU>(inputSize: 64, outputSize: 10)
Softmax<Float, CPU>()
}
model
will have a type Sequential<Sequential<Dense<Float, CPU>, Relu<Float, CPU>>, Sequential<Dense<Float, CPU>, Softmax<Float, CPU>>>
.
-
First transform
Declaration
Swift
public var first: First
-
Second transform
Declaration
Swift
public var second: Second
-
Tag for debugging purposes
Declaration
Swift
public var tag: String?
-
Declaration
Swift
public var parameters: [Tensor<First.Parameter, First.Device>] { get }
-
A sequential layer that concatenates the computations of two other layers.
Declaration
Swift
public init(first: First, second: Second)
Parameters
first
First transform
second
Second transform
-
Declaration
Swift
public var parameterPaths: [WritableKeyPath<`Self`, Tensor<First.Parameter, First.Device>>] { get }
-
Declaration
Swift
public func callAsFunction(_ inputs: First.Inputs) -> Second.Outputs
-
Creates a sequential layer with the sequence of transforms, that is specified in the provided layer builder builder closure.
Example:
Sequential { Dense<Float, CPU>(inputSize: 32, outputSize: 64) Relu<Float, CPU>() Dense<Float, CPU>(inputSize: 64, outputSize: 10) Softmax<Float, CPU>() }
Declaration
Swift
init(@LayerBuilder _ build: () -> `Self`)
Parameters
build
Build block (function builder)