11using System ;
22using System . ComponentModel ;
3- using System . Collections . Generic ;
43using System . Reactive . Linq ;
54using System . Xml . Serialization ;
65using TorchSharp ;
7- using TorchSharp . Modules ;
86using static TorchSharp . torch ;
97using static TorchSharp . torch . nn ;
108
@@ -13,61 +11,58 @@ namespace Bonsai.ML.Torch.NeuralNets.Convolution;
1311/// <summary>
1412/// Represents an operator that creates a 1D convolution module.
1513/// </summary>
14+ /// <remarks>
15+ /// See <see href="https://pytorch.org/docs/stable/generated/torch.nn.Conv1d.html"/> for more information.
16+ /// </remarks>
1617[ Description ( "Creates a 1D convolution module." ) ]
1718public class Conv1d
1819{
1920 /// <summary>
20- /// The in_channels parameter for the Conv1d module .
21+ /// The number of input channels in the input tensor .
2122 /// </summary>
22- [ Description ( "The in_channels parameter for the Conv1d module " ) ]
23+ [ Description ( "The number of input channels in the input tensor. " ) ]
2324 public long InChannels { get ; set ; }
2425
2526 /// <summary>
26- /// The out_channels parameter for the Conv1d module .
27+ /// The number of output channels produced by the convolution .
2728 /// </summary>
28- [ Description ( "The out_channels parameter for the Conv1d module " ) ]
29+ [ Description ( "The number of output channels produced by the convolution. " ) ]
2930 public long OutChannels { get ; set ; }
3031
3132 /// <summary>
32- /// The kernelsize parameter for the Conv1d module .
33+ /// The size of the convolution kernel .
3334 /// </summary>
34- [ Description ( "The kernelsize parameter for the Conv1d module " ) ]
35+ [ Description ( "The size of the convolution kernel. " ) ]
3536 public long KernelSize { get ; set ; }
3637
3738 /// <summary>
38- /// The stride parameter for the Conv1d module .
39+ /// The stride of the convolution .
3940 /// </summary>
40- [ Description ( "The stride parameter for the Conv1d module " ) ]
41+ [ Description ( "The stride of the convolution. " ) ]
4142 public long Stride { get ; set ; } = 1 ;
4243
4344 /// <summary>
44- /// The padding parameter for the Conv1d module .
45+ /// The padding added to both sides of the input .
4546 /// </summary>
46- [ Description ( "The padding parameter for the Conv1d module " ) ]
47+ [ Description ( "The padding added to both sides of the input. " ) ]
4748 public long Padding { get ; set ; } = 0 ;
4849
4950 /// <summary>
50- /// The output_padding parameter for the Conv1d module .
51+ /// The spacing between kernel elements .
5152 /// </summary>
52- [ Description ( "The output_padding parameter for the ConvTransposed1d module" ) ]
53- public long OutputPadding { get ; set ; } = 0 ;
54-
55- /// <summary>
56- /// The dilation parameter for the Conv1d module.
57- /// </summary>
58- [ Description ( "The dilation parameter for the Conv1d module" ) ]
53+ [ Description ( "The spacing between kernel elements." ) ]
5954 public long Dilation { get ; set ; } = 1 ;
6055
6156 /// <summary>
62- /// The padding_mode parameter for the Conv1d module .
57+ /// The mode of padding .
6358 /// </summary>
64- [ Description ( "The padding_mode parameter for the Conv1d module " ) ]
59+ [ Description ( "The mode of padding. " ) ]
6560 public PaddingModes PaddingMode { get ; set ; } = PaddingModes . Zeros ;
6661
6762 /// <summary>
68- /// The groups parameter for the Conv1d module .
63+ /// The number of blocked connections from input channels to output channels .
6964 /// </summary>
70- [ Description ( "The groups parameter for the Conv1d module " ) ]
65+ [ Description ( "The number of blocked connections from input channels to output channels. " ) ]
7166 public long Groups { get ; set ; } = 1 ;
7267
7368 /// <summary>
@@ -77,21 +72,22 @@ public class Conv1d
7772 public bool Bias { get ; set ; } = true ;
7873
7974 /// <summary>
80- /// The desired device of returned tensor.
75+ /// The desired device of the returned tensor.
8176 /// </summary>
8277 [ XmlIgnore ]
83- [ Description ( "The desired device of returned tensor" ) ]
78+ [ Description ( "The desired device of the returned tensor" ) ]
8479 public Device Device { get ; set ; } = null ;
8580
8681 /// <summary>
87- /// The desired data type of returned tensor.
82+ /// The desired data type of the returned tensor.
8883 /// </summary>
89- [ Description ( "The desired data type of returned tensor" ) ]
84+ [ Description ( "The desired data type of the returned tensor" ) ]
9085 public ScalarType ? Type { get ; set ; } = null ;
9186
9287 /// <summary>
9388 /// Creates a Conv1d module.
9489 /// </summary>
90+ /// <returns></returns>
9591 public IObservable < Module < Tensor , Tensor > > Process ( )
9692 {
9793 return Observable . Return ( Conv1d ( InChannels , OutChannels , KernelSize , Stride , Padding , Dilation , PaddingMode , Groups , Bias , Device , Type ) ) ;
@@ -103,7 +99,6 @@ public IObservable<Module<Tensor, Tensor>> Process()
10399 /// <typeparam name="T"></typeparam>
104100 /// <param name="source"></param>
105101 /// <returns></returns>
106- /// <exception cref="InvalidOperationException"></exception>
107102 public IObservable < Module < Tensor , Tensor > > Process < T > ( IObservable < T > source )
108103 {
109104 return source . Select ( _ => Conv1d ( InChannels , OutChannels , KernelSize , Stride , Padding , Dilation , PaddingMode , Groups , Bias , Device , Type ) ) ;
0 commit comments