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

Fix ParameterlessLayer conformances. #620

Merged
merged 1 commit into from
Jul 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions FastStyleTransfer/Layers/Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import TensorFlow

/// A 2-D layer applying padding with reflection over a mini-batch.
public struct ReflectionPad2D<Scalar: TensorFlowFloatingPoint>: ParameterlessLayer {
public typealias TangentVector = EmptyTangentVector

/// The padding values along the spatial dimensions.
@noDerivative public let padding: ((Int, Int), (Int, Int))

Expand Down Expand Up @@ -39,6 +41,8 @@ public struct ReflectionPad2D<Scalar: TensorFlowFloatingPoint>: ParameterlessLay

/// A layer applying `relu` activation function.
public struct ReLU<Scalar: TensorFlowFloatingPoint>: ParameterlessLayer {
public typealias TangentVector = EmptyTangentVector

/// Returns the output obtained from applying the layer to the given input.
///
/// - Parameter input: The input to the layer.
Expand Down
2 changes: 2 additions & 0 deletions Models/ImageClassification/ShuffleNetV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import TensorFlow
// Ningning Ma, Xiangyu Zhang, Hai-Tao Zheng, Jian Sun

public struct ChannelShuffle: ParameterlessLayer {
public typealias TangentVector = EmptyTangentVector

@noDerivative public var groups: Int

public init(groups: Int = 2) {
Expand Down
2 changes: 2 additions & 0 deletions Models/Text/GPT2/TransformerLM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ func _vjpCausallyMasked(_ dotProducts: Tensor<Float>, enable: Bool)
}

struct Attention: ParameterlessLayer {
typealias TangentVector = EmptyTangentVector

@noDerivative var dropout: Dropout<Float>
@noDerivative var scale: Tensor<Float>
@noDerivative var causal: Bool
Expand Down
2 changes: 2 additions & 0 deletions pix2pix/Layers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import TensorFlow
import Foundation

public struct Identity: ParameterlessLayer {
public typealias TangentVector = EmptyTangentVector

@differentiable
public func callAsFunction(_ input: Tensor<Float>) -> Tensor<Float> {
input
Expand Down