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

Commit d0c95c9

Browse files
Shashi456saeta
authored andcommitted
Add migration instructions to deprecation messages (#396)
1 parent c767471 commit d0c95c9

File tree

1 file changed

+54
-20
lines changed

1 file changed

+54
-20
lines changed

Sources/TensorFlow/BackwardsCompatibility.swift

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// TODO: Remove this file after 0.4.
1616

1717
public extension Tensor where Scalar == Int32 {
18-
/// Creates a tensor with the specified shape, randomly sampling scalar values from a discrete
18+
/// Creates a tensor with the specified shape, randomly sampling scalar values from a discrete
1919
/// uniform distribution.
2020
///
2121
/// - Parameters:
@@ -40,7 +40,7 @@ public extension Tensor where Scalar == Int32 {
4040
self.init(shape: shape, scalars: scalars)
4141
}
4242

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

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

92-
/// Creates a tensor with the specified shape, randomly sampling scalar values from a normal
92+
/// Creates a tensor with the specified shape, randomly sampling scalar values from a normal
9393
/// distribution.
9494
///
9595
/// - Parameters:
@@ -128,7 +128,7 @@ public extension Tensor where Scalar: TensorFlowFloatingPoint {
128128
let uniform = Tensor(randomUniform: shape, generator: &generator)
129129
self = Tensor.glorot(fromStandardUniform: uniform, shape: shape)
130130
}
131-
131+
132132
/// Performs Glorot normal initialization for the specified shape, creating a tensor by
133133
/// randomly sampling scalar values from a uniform distribution between `-limit` and `limit`,
134134
/// where limit is `sqrt(2 / (fanIn + fanOut))` and `fanIn`/`fanOut` represent the number of
@@ -200,7 +200,11 @@ public extension Conv1D where Scalar.RawSignificand: FixedWidthInteger {
200200
///
201201
/// - Note: Use `init(filterShape:stride:padding:dilation:activation:seed:)` for faster random
202202
/// initialization.
203-
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
203+
@available(*, deprecated, message: """
204+
This API will be removed after Swift for TensorFlow 0.4, please consider using
205+
`init(filterShape:stride:padding:dilation:activation:filterIntializer:biasInitializer:)`
206+
instead.
207+
""")
204208
init<G: RandomNumberGenerator>(
205209
filterShape: (Int, Int, Int),
206210
stride: Int = 1,
@@ -221,18 +225,22 @@ public extension Conv1D where Scalar.RawSignificand: FixedWidthInteger {
221225
}
222226
}
223227

224-
public extension Conv1D {
225-
/// Creates a `Conv1D` layer with the specified filter shape, strides, padding, dilation and
226-
/// element-wise activation function. The filter tensor is initialized using Glorot uniform
227-
/// initialization with the specified seed. The bias vector is initialized with zeros.
228+
public extension Conv1D {
229+
/// Creates a `Conv1D` layer with the specified filter shape, strides, padding, dilation and
230+
/// element-wise activation function. The filter tensor is initialized using Glorot uniform
231+
/// initialization with the specified seed. The bias vector is initialized with zeros.
228232
///
229233
/// - Parameters:
230-
/// - filterShape: The 3-D shape of the filter, representing
234+
/// - filterShape: The 3-D shape of the filter, representing
231235
/// - padding: The padding algorithm for convolution.
232236
/// - dilation: The dilation factor for the temporal dimension.
233237
/// - activation: The element-wise activation function.
234238
/// - seed: The random seed for initialization. The default value is random.
235-
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
239+
@available(*, deprecated, message: """
240+
This API will be removed after Swift for TensorFlow 0.4, please consider using
241+
`init(filterShape:stride:padding:dilation:activation:filterIntializer:biasInitializer:)`
242+
instead.
243+
""")
236244
init(
237245
filterShape: (Int, Int, Int),
238246
stride: Int = 1,
@@ -271,7 +279,11 @@ public extension Conv2D {
271279
///
272280
/// - Note: Use `init(filterShape:strides:padding:activation:seed:)` for faster random
273281
/// initialization.
274-
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
282+
@available(*, deprecated, message: """
283+
This API will be removed after Swift for TensorFlow 0.4, please consider using
284+
`init(filterShape:strides:padding:dilations:activation:filterIntializer:biasInitializer:)`
285+
instead.
286+
""")
275287
init<G: RandomNumberGenerator>(
276288
filterShape: (Int, Int, Int, Int),
277289
strides: (Int, Int) = (1, 1),
@@ -307,7 +319,11 @@ public extension Conv2D {
307319
/// (dilation height, dilation width).
308320
/// - activation: The element-wise activation function.
309321
/// - seed: The random seed for initialization. The default value is random.
310-
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
322+
@available(*, deprecated, message: """
323+
This API will be removed after Swift for TensorFlow 0.4, please consider using
324+
`init(filterShape:strides:padding:dilations:activation:filterIntializer:biasInitializer:)`
325+
instead.
326+
""")
311327
init(
312328
filterShape: (Int, Int, Int, Int),
313329
strides: (Int, Int) = (1, 1),
@@ -345,7 +361,10 @@ public extension Conv3D {
345361
///
346362
/// - Note: Use `init(filterShape:strides:padding:activation:seed:)` for faster random
347363
/// initialization.
348-
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
364+
@available(*, deprecated, message: """
365+
This API will be removed after Swift for TensorFlow 0.4, please consider using
366+
`init(filterShape:strides:padding:activation:filterIntializer:biasInitializer:)` instead.
367+
""")
349368
init<G: RandomNumberGenerator>(
350369
filterShape: (Int, Int, Int, Int, Int),
351370
strides: (Int, Int, Int) = (1, 1, 1),
@@ -378,7 +397,10 @@ public extension Conv3D {
378397
/// - padding: The padding algorithm for convolution.
379398
/// - activation: The element-wise activation function.
380399
/// - seed: The random seed for initialization. The default value is random.
381-
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
400+
@available(*, deprecated, message: """
401+
This API will be removed after Swift for TensorFlow 0.4, please consider using
402+
`init(filterShape:strides:padding:activation:filterIntializer:biasInitializer:)` instead.
403+
""")
382404
init(
383405
filterShape: (Int, Int, Int, Int, Int),
384406
strides: (Int, Int, Int) = (1, 1, 1),
@@ -412,7 +434,10 @@ public extension TransposedConv2D {
412434
///
413435
/// - Note: Use `init(filterShape:strides:padding:activation:seed:)` for faster random
414436
/// initialization.
415-
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
437+
@available(*, deprecated, message: """
438+
This API will be removed after Swift for TensorFlow 0.4, please consider using
439+
`init(filterShape:strides:padding:activation:filterIntializer:biasInitializer:)` instead.
440+
""")
416441
init<G: RandomNumberGenerator>(
417442
filterShape: (Int, Int, Int, Int),
418443
strides: (Int, Int) = (1, 1),
@@ -443,7 +468,10 @@ public extension TransposedConv2D {
443468
/// - padding: The padding algorithm for convolution.
444469
/// - activation: The element-wise activation function.
445470
/// - seed: The random seed for initialization. The default value is random.
446-
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
471+
@available(*, deprecated, message: """
472+
This API will be removed after Swift for TensorFlow 0.4, please consider using
473+
`init(filterShape:strides:padding:activation:filterIntializer:biasInitializer:)` instead.
474+
""")
447475
init(
448476
filterShape: (Int, Int, Int, Int),
449477
strides: (Int, Int) = (1, 1),
@@ -476,7 +504,10 @@ public extension DepthwiseConv2D {
476504
///
477505
/// - Note: Use `init(filterShape:strides:padding:activation:seed:)` for faster random
478506
/// initialization.
479-
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
507+
@available(*, deprecated, message: """
508+
This API will be removed after Swift for TensorFlow 0.4, please consider using
509+
`init(filterShape:strides:padding:activation:filterIntializer:biasInitializer:)` instead.
510+
""")
480511
init<G: RandomNumberGenerator>(
481512
filterShape: (Int, Int, Int, Int),
482513
strides: (Int, Int) = (1, 1),
@@ -506,7 +537,10 @@ public extension DepthwiseConv2D {
506537
/// - padding: The padding algorithm for convolution.
507538
/// - activation: The element-wise activation function.
508539
/// - seed: The random seed for initialization. The default value is random.
509-
@available(*, deprecated, message: "This API will be removed after Swift for TensorFlow 0.4.")
540+
@available(*, deprecated, message: """
541+
This API will be removed after Swift for TensorFlow 0.4, please consider using
542+
`init(filterShape:strides:padding:activation:filterIntializer:biasInitializer:)` instead.
543+
""")
510544
init(
511545
filterShape: (Int, Int, Int, Int),
512546
strides: (Int, Int) = (1, 1),

0 commit comments

Comments
 (0)