Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Add migration instructions to deprecation messages #396

Merged
merged 2 commits into from
Jul 27, 2019
Merged
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
74 changes: 54 additions & 20 deletions Sources/TensorFlow/BackwardsCompatibility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// TODO: Remove this file after 0.4.

public extension Tensor where Scalar == Int32 {
/// Creates a tensor with the specified shape, randomly sampling scalar values from a discrete
/// Creates a tensor with the specified shape, randomly sampling scalar values from a discrete
/// uniform distribution.
///
/// - Parameters:
Expand All @@ -40,7 +40,7 @@ public extension Tensor where Scalar == Int32 {
self.init(shape: shape, scalars: scalars)
}

/// Creates a tensor with the specified shape, randomly sampling scalar values from a discrete
/// Creates a tensor with the specified shape, randomly sampling scalar values from a discrete
/// uniform distribution, using the default random number generator.
///
/// - Parameters:
Expand All @@ -63,7 +63,7 @@ public extension Tensor where Scalar == Int32 {

public extension Tensor where Scalar: BinaryFloatingPoint,
Scalar.RawSignificand: FixedWidthInteger {
/// Creates a tensor with the specified shape, randomly sampling scalar values from a uniform
/// Creates a tensor with the specified shape, randomly sampling scalar values from a uniform
/// distribution between `lowerBound` and `upperBound`.
///
/// - Parameters:
Expand All @@ -89,7 +89,7 @@ public extension Tensor where Scalar: BinaryFloatingPoint,
self = (upperBound - lowerBound) * sample + lowerBound
}

/// Creates a tensor with the specified shape, randomly sampling scalar values from a normal
/// Creates a tensor with the specified shape, randomly sampling scalar values from a normal
/// distribution.
///
/// - Parameters:
Expand Down Expand Up @@ -128,7 +128,7 @@ public extension Tensor where Scalar: TensorFlowFloatingPoint {
let uniform = Tensor(randomUniform: shape, generator: &generator)
self = Tensor.glorot(fromStandardUniform: uniform, shape: shape)
}

/// Performs Glorot normal initialization for the specified shape, creating a tensor by
/// randomly sampling scalar values from a uniform distribution between `-limit` and `limit`,
/// where limit is `sqrt(2 / (fanIn + fanOut))` and `fanIn`/`fanOut` represent the number of
Expand Down Expand Up @@ -200,7 +200,11 @@ public extension Conv1D where Scalar.RawSignificand: FixedWidthInteger {
///
/// - Note: Use `init(filterShape:stride:padding:dilation:activation:seed:)` for faster random
/// initialization.
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
@available(*, deprecated, message: """
This API will be removed after Swift for TensorFlow 0.4, please consider using
`init(filterShape:stride:padding:dilation:activation:filterIntializer:biasInitializer:)`
instead.
""")
init<G: RandomNumberGenerator>(
filterShape: (Int, Int, Int),
stride: Int = 1,
Expand All @@ -221,18 +225,22 @@ public extension Conv1D where Scalar.RawSignificand: FixedWidthInteger {
}
}

public extension Conv1D {
/// Creates a `Conv1D` layer with the specified filter shape, strides, padding, dilation and
/// element-wise activation function. The filter tensor is initialized using Glorot uniform
/// initialization with the specified seed. The bias vector is initialized with zeros.
public extension Conv1D {
/// Creates a `Conv1D` layer with the specified filter shape, strides, padding, dilation and
/// element-wise activation function. The filter tensor is initialized using Glorot uniform
/// initialization with the specified seed. The bias vector is initialized with zeros.
///
/// - Parameters:
/// - filterShape: The 3-D shape of the filter, representing
/// - filterShape: The 3-D shape of the filter, representing
/// - padding: The padding algorithm for convolution.
/// - dilation: The dilation factor for the temporal dimension.
/// - activation: The element-wise activation function.
/// - seed: The random seed for initialization. The default value is random.
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
@available(*, deprecated, message: """
This API will be removed after Swift for TensorFlow 0.4, please consider using
`init(filterShape:stride:padding:dilation:activation:filterIntializer:biasInitializer:)`
instead.
""")
init(
filterShape: (Int, Int, Int),
stride: Int = 1,
Expand Down Expand Up @@ -271,7 +279,11 @@ public extension Conv2D {
///
/// - Note: Use `init(filterShape:strides:padding:activation:seed:)` for faster random
/// initialization.
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
@available(*, deprecated, message: """
This API will be removed after Swift for TensorFlow 0.4, please consider using
`init(filterShape:strides:padding:dilations:activation:filterIntializer:biasInitializer:)`
instead.
""")
init<G: RandomNumberGenerator>(
filterShape: (Int, Int, Int, Int),
strides: (Int, Int) = (1, 1),
Expand Down Expand Up @@ -307,7 +319,11 @@ public extension Conv2D {
/// (dilation height, dilation width).
/// - activation: The element-wise activation function.
/// - seed: The random seed for initialization. The default value is random.
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
@available(*, deprecated, message: """
This API will be removed after Swift for TensorFlow 0.4, please consider using
`init(filterShape:strides:padding:dilations:activation:filterIntializer:biasInitializer:)`
instead.
""")
init(
filterShape: (Int, Int, Int, Int),
strides: (Int, Int) = (1, 1),
Expand Down Expand Up @@ -345,7 +361,10 @@ public extension Conv3D {
///
/// - Note: Use `init(filterShape:strides:padding:activation:seed:)` for faster random
/// initialization.
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
@available(*, deprecated, message: """
This API will be removed after Swift for TensorFlow 0.4, please consider using
`init(filterShape:strides:padding:activation:filterIntializer:biasInitializer:)` instead.
""")
init<G: RandomNumberGenerator>(
filterShape: (Int, Int, Int, Int, Int),
strides: (Int, Int, Int) = (1, 1, 1),
Expand Down Expand Up @@ -378,7 +397,10 @@ public extension Conv3D {
/// - padding: The padding algorithm for convolution.
/// - activation: The element-wise activation function.
/// - seed: The random seed for initialization. The default value is random.
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
@available(*, deprecated, message: """
This API will be removed after Swift for TensorFlow 0.4, please consider using
`init(filterShape:strides:padding:activation:filterIntializer:biasInitializer:)` instead.
""")
init(
filterShape: (Int, Int, Int, Int, Int),
strides: (Int, Int, Int) = (1, 1, 1),
Expand Down Expand Up @@ -412,7 +434,10 @@ public extension TransposedConv2D {
///
/// - Note: Use `init(filterShape:strides:padding:activation:seed:)` for faster random
/// initialization.
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
@available(*, deprecated, message: """
This API will be removed after Swift for TensorFlow 0.4, please consider using
`init(filterShape:strides:padding:activation:filterIntializer:biasInitializer:)` instead.
""")
init<G: RandomNumberGenerator>(
filterShape: (Int, Int, Int, Int),
strides: (Int, Int) = (1, 1),
Expand Down Expand Up @@ -443,7 +468,10 @@ public extension TransposedConv2D {
/// - padding: The padding algorithm for convolution.
/// - activation: The element-wise activation function.
/// - seed: The random seed for initialization. The default value is random.
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
@available(*, deprecated, message: """
This API will be removed after Swift for TensorFlow 0.4, please consider using
`init(filterShape:strides:padding:activation:filterIntializer:biasInitializer:)` instead.
""")
init(
filterShape: (Int, Int, Int, Int),
strides: (Int, Int) = (1, 1),
Expand Down Expand Up @@ -476,7 +504,10 @@ public extension DepthwiseConv2D {
///
/// - Note: Use `init(filterShape:strides:padding:activation:seed:)` for faster random
/// initialization.
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
@available(*, deprecated, message: """
This API will be removed after Swift for TensorFlow 0.4, please consider using
`init(filterShape:strides:padding:activation:filterIntializer:biasInitializer:)` instead.
""")
init<G: RandomNumberGenerator>(
filterShape: (Int, Int, Int, Int),
strides: (Int, Int) = (1, 1),
Expand Down Expand Up @@ -506,7 +537,10 @@ public extension DepthwiseConv2D {
/// - padding: The padding algorithm for convolution.
/// - activation: The element-wise activation function.
/// - seed: The random seed for initialization. The default value is random.
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
@available(*, deprecated, message: """
This API will be removed after Swift for TensorFlow 0.4, please consider using
`init(filterShape:strides:padding:activation:filterIntializer:biasInitializer:)` instead.
""")
init(
filterShape: (Int, Int, Int, Int),
strides: (Int, Int) = (1, 1),
Expand Down