I would like to get the shorthand name of a torch::Model, in include/torch/csrc/api/include/torch/nn/module.h
, I found
87 /// Returns the name of the `Module`.
88 ///
89 /// A `Module` has an associated `name`, which is a string representation of
90 /// the kind of concrete `Module` it represents, such as `"Linear"` for the
91 /// `Linear` module. Under most circumstances, this name is automatically
92 /// inferred via runtime type information (RTTI). In the unusual circumstance
93 /// that you have this feature disabled, you may want to manually name your
94 /// `Module`s by passing the string name to the `Module` base class'
95 /// constructor.
96 const std::string& name() const noexcept;
but when I use it for example for Tanh
, I get two different string representations, one by name()
another by the ostream& <<
,
auto tanh = torch::nn::Tanh();
std::cout << tanh->name() << std::endl;
std::cout << tanh << std::endl;
namely,
torch::nn::TanhImpl
torch::nn::Tanh()
I would just like to have “Tanh”, is this readily available without resorting manipulating strings myself?