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

Commit 17c58d7

Browse files
dan-zhengrxwei
authored andcommitted
Improve API documentation. (#114)
- Standardize documentation for `func call(_:)`. - Minor edits to RNN docs.
1 parent 48caccc commit 17c58d7

File tree

1 file changed

+23
-48
lines changed

1 file changed

+23
-48
lines changed

Sources/DeepLearning/Layer.swift

Lines changed: 23 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public protocol Layer: Differentiable & KeyPathIterable
3131

3232
/// Returns the output obtained from applying the layer to the given input.
3333
///
34-
/// - Parameters:
35-
/// - input: The input to the layer.
34+
/// - Parameter input: The input to the layer.
3635
/// - Returns: The output.
3736
@differentiable
3837
func call(_ input: Input) -> Output
@@ -216,8 +215,7 @@ public struct Dense<Scalar: TensorFlowFloatingPoint>: Layer {
216215

217216
/// Returns the output obtained from applying the layer to the given input.
218217
///
219-
/// - Parameters:
220-
/// - input: The input to the layer.
218+
/// - Parameter input: The input to the layer.
221219
/// - Returns: The output.
222220
@differentiable
223221
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -325,8 +323,7 @@ public struct Conv1D<Scalar: TensorFlowFloatingPoint>: Layer {
325323

326324
/// Returns the output obtained from applying the layer to the given input.
327325
///
328-
/// - Parameters:
329-
/// - input: The input to the layer `[batchCount, width, inputChannels]`.
326+
/// - Parameter input: The input to the layer `[batchCount, width, inputChannels]`.
330327
/// - Returns: The output `[batchCount, newWidth, outputChannels]`.
331328
@differentiable
332329
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -444,8 +441,7 @@ public struct Conv2D<Scalar: TensorFlowFloatingPoint>: Layer {
444441

445442
/// Returns the output obtained from applying the layer to the given input.
446443
///
447-
/// - Parameters:
448-
/// - input: The input to the layer.
444+
/// - Parameter input: The input to the layer.
449445
/// - Returns: The output.
450446
@differentiable
451447
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -563,8 +559,7 @@ public struct TransposedConv2D: Layer {
563559

564560
/// Returns the output obtained from applying the layer to the given input.
565561
///
566-
/// - Parameters:
567-
/// - input: The input to the layer.
562+
/// - Parameter input: The input to the layer.
568563
/// - Returns: The output.
569564
@differentiable
570565
public func call(_ input: Tensor<Float>) -> Tensor<Float> {
@@ -718,8 +713,7 @@ public struct BatchNorm<Scalar: TensorFlowFloatingPoint>: Layer {
718713

719714
/// Returns the output obtained from applying the layer to the given input.
720715
///
721-
/// - Parameters:
722-
/// - input: The input to the layer.
716+
/// - Parameter input: The input to the layer.
723717
/// - Returns: The output.
724718
@differentiable(vjp: _vjpApplied(to:))
725719
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -796,8 +790,7 @@ public struct MaxPool1D<Scalar: TensorFlowFloatingPoint>: Layer {
796790

797791
/// Returns the output obtained from applying the layer to the given input.
798792
///
799-
/// - Parameters:
800-
/// - input: The input to the layer.
793+
/// - Parameter input: The input to the layer.
801794
/// - Returns: The output.
802795
@differentiable
803796
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -843,8 +836,7 @@ public struct MaxPool2D<Scalar: TensorFlowFloatingPoint>: Layer {
843836

844837
/// Returns the output obtained from applying the layer to the given input.
845838
///
846-
/// - Parameters:
847-
/// - input: The input to the layer.
839+
/// - Parameter input: The input to the layer.
848840
/// - Returns: The output.
849841
@differentiable
850842
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -881,8 +873,7 @@ public struct AvgPool1D<Scalar: TensorFlowFloatingPoint>: Layer {
881873

882874
/// Returns the output obtained from applying the layer to the given input.
883875
///
884-
/// - Parameters:
885-
/// - input: The input to the layer.
876+
/// - Parameter input: The input to the layer.
886877
/// - Returns: The output.
887878
@differentiable
888879
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -928,8 +919,7 @@ public struct AvgPool2D<Scalar: TensorFlowFloatingPoint>: Layer {
928919

929920
/// Returns the output obtained from applying the layer to the given input.
930921
///
931-
/// - Parameters:
932-
/// - input: The input to the layer.
922+
/// - Parameter input: The input to the layer.
933923
/// - Returns: The output.
934924
@differentiable
935925
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -946,8 +936,7 @@ public struct GlobalAvgPool1D<Scalar: TensorFlowFloatingPoint>: Layer {
946936

947937
/// Returns the output obtained from applying the layer to the given input.
948938
///
949-
/// - Parameters:
950-
/// - input: The input to the layer.
939+
/// - Parameter input: The input to the layer.
951940
/// - Returns: The output.
952941
@differentiable
953942
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -963,8 +952,7 @@ public struct GlobalAvgPool2D<Scalar: TensorFlowFloatingPoint>: Layer {
963952

964953
/// Returns the output obtained from applying the layer to the given input.
965954
///
966-
/// - Parameters:
967-
/// - input: The input to the layer.
955+
/// - Parameter input: The input to the layer.
968956
/// - Returns: The output.
969957
@differentiable
970958
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -980,8 +968,7 @@ public struct GlobalAvgPool3D<Scalar: TensorFlowFloatingPoint>: Layer {
980968

981969
/// Returns the output obtained from applying the layer to the given input.
982970
///
983-
/// - Parameters:
984-
/// - input: The input to the layer.
971+
/// - Parameter input: The input to the layer.
985972
/// - Returns: The output.
986973
@differentiable
987974
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -1035,8 +1022,7 @@ public struct LayerNorm<Scalar: TensorFlowFloatingPoint>: Layer {
10351022

10361023
/// Returns the output obtained from applying the layer to the given input.
10371024
///
1038-
/// - Parameters:
1039-
/// - input: The input to the layer.
1025+
/// - Parameter input: The input to the layer.
10401026
/// - Returns: The output.
10411027
@differentiable
10421028
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -1085,8 +1071,7 @@ public struct Dropout<Scalar: TensorFlowFloatingPoint>: Layer {
10851071

10861072
/// Returns the output obtained from applying the layer to the given input.
10871073
///
1088-
/// - Parameters:
1089-
/// - input: The input to the layer.
1074+
/// - Parameter input: The input to the layer.
10901075
/// - Returns: The output.
10911076
@differentiable(vjp: _vjpApplied(to:))
10921077
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -1129,8 +1114,7 @@ public struct UpSampling1D<Scalar: TensorFlowFloatingPoint>: Layer {
11291114

11301115
/// Returns the output obtained from applying the layer to the given input.
11311116
///
1132-
/// - Parameters:
1133-
/// - input: The input to the layer.
1117+
/// - Parameter input: The input to the layer.
11341118
/// - Returns: The output.
11351119
@differentiable
11361120
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -1156,8 +1140,7 @@ public struct UpSampling2D<Scalar: TensorFlowFloatingPoint>: Layer {
11561140

11571141
/// Returns the output obtained from applying the layer to the given input.
11581142
///
1159-
/// - Parameters:
1160-
/// - input: The input to the layer.
1143+
/// - Parameter input: The input to the layer.
11611144
/// - Returns: The output.
11621145
@differentiable
11631146
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -1179,8 +1162,7 @@ public struct Flatten<Scalar: TensorFlowFloatingPoint>: Layer {
11791162

11801163
/// Returns the output obtained from applying the layer to the given input.
11811164
///
1182-
/// - Parameters:
1183-
/// - input: The input to the layer.
1165+
/// - Parameter input: The input to the layer.
11841166
/// - Returns: The output.
11851167
@differentiable
11861168
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -1216,8 +1198,7 @@ public struct Reshape<Scalar: TensorFlowFloatingPoint>: Layer {
12161198

12171199
/// Returns the output obtained from applying the layer to the given input.
12181200
///
1219-
/// - Parameters:
1220-
/// - input: The input to the layer.
1201+
/// - Parameter input: The input to the layer.
12211202
/// - Returns: The output.
12221203
@differentiable
12231204
public func call(_ input: Tensor<Scalar>) -> Tensor<Scalar> {
@@ -1280,7 +1261,7 @@ public extension RNNCell {
12801261
}
12811262
}
12821263

1283-
/// A Simple RNN Cell.
1264+
/// A simple RNN cell.
12841265
public struct SimpleRNNCell<Scalar: TensorFlowFloatingPoint>: RNNCell, VectorNumeric {
12851266
public var weight: Tensor<Scalar>
12861267
public var bias: Tensor<Scalar>
@@ -1316,10 +1297,7 @@ public struct SimpleRNNCell<Scalar: TensorFlowFloatingPoint>: RNNCell, VectorNum
13161297

13171298
/// Returns the output obtained from applying the layer to the given input.
13181299
///
1319-
/// - Parameters:
1320-
/// - input: The input to the layer.
1321-
/// - context: The contextual information for the layer application, e.g. the current learning
1322-
/// phase.
1300+
/// - Parameter input: The input to the layer.
13231301
/// - Returns: The hidden state.
13241302
@differentiable
13251303
public func call(_ input: Input) -> Output {
@@ -1329,7 +1307,7 @@ public struct SimpleRNNCell<Scalar: TensorFlowFloatingPoint>: RNNCell, VectorNum
13291307
}
13301308
}
13311309

1332-
/// An LSTM Cell.
1310+
/// An LSTM cell.
13331311
public struct LSTMCell<Scalar: TensorFlowFloatingPoint>: RNNCell, VectorNumeric {
13341312
public var inputWeight, updateWeight, forgetWeight, outputWeight: Tensor<Scalar>
13351313
public var inputBias, updateBias, forgetBias, outputBias: Tensor<Scalar>
@@ -1381,10 +1359,7 @@ public struct LSTMCell<Scalar: TensorFlowFloatingPoint>: RNNCell, VectorNumeric
13811359

13821360
/// Returns the output obtained from applying the layer to the given input.
13831361
///
1384-
/// - Parameters:
1385-
/// - input: The input to the layer.
1386-
/// - context: The contextual information for the layer application, e.g. the current learning
1387-
/// phase.
1362+
/// - Parameter input: The input to the layer.
13881363
/// - Returns: The hidden state.
13891364
@differentiable
13901365
public func call(_ input: Input) -> Output {

0 commit comments

Comments
 (0)