Class LinearImpl¶
Defined in File linear.h
Page Contents
Inheritance Relationships¶
Base Type¶
public torch::nn::Cloneable< LinearImpl >
(Template Class Cloneable)
Class Documentation¶
-
class LinearImpl : public torch::nn::Cloneable<LinearImpl>¶
Applies a linear transformation with optional bias.
See https://pytorch.org/docs/main/generated/torch.nn.Linear.html to learn about the exact behavior of this module.
See the documentation for
torch::nn::LinearOptions
class to learn what constructor arguments are supported for this module.Example:
Linear model(LinearOptions(5, 2).bias(false));
Public Functions
-
inline LinearImpl(int64_t in_features, int64_t out_features)¶
-
explicit LinearImpl(const LinearOptions &options_)¶
-
virtual void reset() override¶
reset()
must perform initialization of all members with reference semantics, most importantly parameters, buffers and submodules.
-
void reset_parameters()¶
-
virtual void pretty_print(std::ostream &stream) const override¶
Pretty prints the
Linear
module into the givenstream
.
-
Tensor forward(const Tensor &input)¶
Transforms the
input
tensor by multiplying with theweight
and optionally adding thebias
, ifwith_bias
is true in the options.
Public Members
-
LinearOptions options¶
The options used to configure this module.
-
Tensor weight¶
The learned weight.
-
Tensor bias¶
The learned bias.
If
bias
is false in theoptions
, this tensor is undefined.
-
inline LinearImpl(int64_t in_features, int64_t out_features)¶