72 virtual torch::Tensor
apply(
const torch::Tensor &input)
const = 0;
83 virtual torch::serialize::OutputArchive &
84 write(torch::serialize::OutputArchive &archive,
85 const std::string &key)
const = 0;
92 virtual torch::serialize::InputArchive &
93 read(torch::serialize::InputArchive &archive,
const std::string &key) = 0;
112 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
127 inline torch::serialize::OutputArchive &
128 write(torch::serialize::OutputArchive &archive,
129 const std::string &key =
"none")
const override {
130 archive.write(key +
".type",
141 inline torch::serialize::InputArchive &
142 read(torch::serialize::InputArchive &archive,
143 const std::string &key =
"none")
override {
144 torch::Tensor tensor;
146 archive.read(key +
".type", tensor);
148 throw std::runtime_error(
"activation mismatch");
166 torch::nn::functional::BatchNormFuncOptions
options = {})
179 const torch::Tensor &weight,
const torch::Tensor &bias,
180 double eps,
double momentum,
bool training =
false)
186 .training(training)),
195 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
218 inline const torch::nn::functional::BatchNormFuncOptions &
options()
const {
224 inline torch::nn::functional::BatchNormFuncOptions &
options() {
235#if TORCH_VERSION_MAJOR >= 2 && TORCH_VERSION_MINOR < 7
238 <<
", training=" <<
options_.training();
243 <<
"\n weight = " <<
options_.weight()
255 inline torch::serialize::OutputArchive &
256 write(torch::serialize::OutputArchive &archive,
257 const std::string &key =
"batch_norm")
const override {
258 archive.write(key +
".type", torch::full({1},
static_cast<int64_t
>(
260 archive.write(key +
".running_mean", this->
running_mean());
261 archive.write(key +
".running_var", this->
running_var());
262 archive.write(key +
".weight", this->
options_.weight());
263 archive.write(key +
".bias", this->
options_.bias());
264 archive.write(key +
".eps", torch::full({1}, (double)this->
options_.eps()));
265 archive.write(key +
".momentum", torch::full({1}, (double)this->
options_
267#if TORCH_VERSION_MAJOR >= 2 && TORCH_VERSION_MINOR < 7
271 archive.write(key +
".training",
272 torch::full({1}, (bool)this->
options_.training()));
282 inline torch::serialize::InputArchive &
283 read(torch::serialize::InputArchive &archive,
284 const std::string &key =
"batch_norm")
override {
285 torch::Tensor tensor;
287 archive.read(key +
".type", tensor);
289 throw std::runtime_error(
"activation mismatch");
291 archive.read(key +
".running_mean", this->
running_mean());
292 archive.read(key +
".running_var", this->
running_var());
293 archive.read(key +
".weight", this->
options_.weight());
294 archive.read(key +
".bias", this->
options_.bias());
295 archive.read(key +
".eps", tensor);
296 this->
options_.eps(tensor.item<
double>());
297 archive.read(key +
".momentum", tensor);
298 this->
options_.momentum(tensor.item<
double>());
299 archive.read(key +
".training", tensor);
300 this->
options_.training(tensor.item<
bool>());
306 torch::nn::functional::BatchNormFuncOptions
options_;
320 explicit CELU(torch::nn::functional::CELUFuncOptions
options = {})
326 explicit CELU(
double alpha,
bool inplace =
false)
327 :
options_(
torch::nn::functional::CELUFuncOptions().alpha(alpha).inplace(
335 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
336 return torch::nn::functional::celu(input,
options_);
341 inline const torch::nn::functional::CELUFuncOptions &
options()
const {
353 <<
", inplace=" <<
options_.inplace() <<
"\n)";
361 inline torch::serialize::OutputArchive &
362 write(torch::serialize::OutputArchive &archive,
363 const std::string &key =
"celu")
const override {
364 archive.write(key +
".type",
366 archive.write(key +
".alpha",
367 torch::full({1}, (double)this->
options_.alpha()));
368 archive.write(key +
".inplace",
369 torch::full({1}, (bool)this->
options_.inplace()));
379 inline torch::serialize::InputArchive &
380 read(torch::serialize::InputArchive &archive,
381 const std::string &key =
"celu")
override {
382 torch::Tensor tensor;
384 archive.read(key +
".type", tensor);
386 throw std::runtime_error(
"activation mismatch");
388 archive.read(key +
".alpha", tensor);
389 this->
options_.alpha(tensor.item<
double>());
390 archive.read(key +
".inplace", tensor);
391 this->
options_.inplace(tensor.item<
bool>());
413 explicit ELU(torch::nn::functional::ELUFuncOptions
options = {})
419 explicit ELU(
double alpha,
bool inplace =
false)
420 :
options_(
torch::nn::functional::ELUFuncOptions().alpha(alpha).inplace(
428 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
429 return torch::nn::functional::elu(input,
options_);
434 inline const torch::nn::functional::ELUFuncOptions &
options()
const {
447 <<
", inplace=" <<
options_.inplace() <<
"\n)";
455 inline torch::serialize::OutputArchive &
456 write(torch::serialize::OutputArchive &archive,
457 const std::string &key =
"elu")
const override {
458 archive.write(key +
".type",
460 archive.write(key +
".alpha",
461 torch::full({1}, (double)this->
options_.alpha()));
462 archive.write(key +
".inplace",
463 torch::full({1}, (bool)this->
options_.inplace()));
473 inline torch::serialize::InputArchive &
474 read(torch::serialize::InputArchive &archive,
475 const std::string &key =
"elu")
override {
476 torch::Tensor tensor;
478 archive.read(key +
".type", tensor);
480 throw std::runtime_error(
"activation mismatch");
482 archive.read(key +
".alpha", tensor);
483 this->
options_.alpha(tensor.item<
double>());
484 archive.read(key +
".inplace", tensor);
485 this->
options_.inplace(tensor.item<
bool>());
511 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
512 return torch::gelu(input);
526 inline torch::serialize::OutputArchive &
527 write(torch::serialize::OutputArchive &archive,
528 const std::string &key =
"gelu")
const override {
529 archive.write(key +
".type",
540 inline torch::serialize::InputArchive &
541 read(torch::serialize::InputArchive &archive,
542 const std::string &key =
"gelu")
override {
543 torch::Tensor tensor;
545 archive.read(key +
".type", tensor);
547 throw std::runtime_error(
"activation mismatch");
566 explicit GLU(torch::nn::functional::GLUFuncOptions
options = {})
572 :
options_(
torch::nn::functional::GLUFuncOptions().dim(dim)) {}
579 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
580 return torch::nn::functional::glu(input,
options_);
585 inline const torch::nn::functional::GLUFuncOptions &
options()
const {
605 inline torch::serialize::OutputArchive &
606 write(torch::serialize::OutputArchive &archive,
607 const std::string &key =
"glu")
const override {
608 archive.write(key +
".type",
610 archive.write(key +
".dim",
611 torch::full({1},
static_cast<int>(this->
options_.dim())));
621 inline torch::serialize::InputArchive &
622 read(torch::serialize::InputArchive &archive,
623 const std::string &key =
"glu")
override {
624 torch::Tensor tensor;
626 archive.read(key +
".type", tensor);
628 throw std::runtime_error(
"activation mismatch");
630 archive.read(key +
".dim", tensor);
631 this->
options_.dim(tensor.item<
int>());
647 :
options_(
torch::nn::functional::GroupNormFuncOptions(num_groups)) {}
659 explicit GroupNorm(int64_t num_groups,
const torch::Tensor &weight,
660 const torch::Tensor &bias,
double eps)
661 :
options_(
torch::nn::functional::GroupNormFuncOptions(num_groups)
671 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
672 return torch::nn::functional::group_norm(input,
options_);
677 inline const torch::nn::functional::GroupNormFuncOptions &
options()
const {
683 inline torch::nn::functional::GroupNormFuncOptions &
options() {
694 os <<
"\n weight = " <<
options_.weight()
706 inline torch::serialize::OutputArchive &
707 write(torch::serialize::OutputArchive &archive,
708 const std::string &key =
"group_norm")
const override {
709 archive.write(key +
".type", torch::full({1},
static_cast<int64_t
>(
711 archive.write(key +
".weight", this->
options_.weight());
712 archive.write(key +
".bias", this->
options_.bias());
713 archive.write(key +
".eps", torch::full({1}, (double)this->
options_.eps()));
723 inline torch::serialize::InputArchive &
724 read(torch::serialize::InputArchive &archive,
725 const std::string &key =
"group_norm")
override {
726 torch::Tensor tensor;
728 archive.read(key +
".type", tensor);
730 throw std::runtime_error(
"activation mismatch");
732 archive.read(key +
".weight", this->
options_.weight());
733 archive.read(key +
".bias", this->
options_.bias());
734 archive.read(key +
".eps", tensor);
735 this->
options_.eps(tensor.item<
double>());
741 torch::nn::functional::GroupNormFuncOptions
options_;
750 torch::nn::functional::GumbelSoftmaxFuncOptions
options = {})
768 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
769 return torch::nn::functional::gumbel_softmax(input,
options_);
774 inline const torch::nn::functional::GumbelSoftmaxFuncOptions &
781 inline torch::nn::functional::GumbelSoftmaxFuncOptions &
options() {
798 inline torch::serialize::OutputArchive &
799 write(torch::serialize::OutputArchive &archive,
800 const std::string &key =
"gumbel_softmax")
const override {
804 archive.write(key +
".tau", torch::full({1}, (double)this->
options_.tau()));
805 archive.write(key +
".dim", torch::full({1}, (int)this->
options_.dim()));
806 archive.write(key +
".hard", torch::full({1}, (bool)this->
options_.hard()));
816 inline torch::serialize::InputArchive &
817 read(torch::serialize::InputArchive &archive,
818 const std::string &key =
"gumbel_softmax")
override {
819 torch::Tensor tensor;
821 archive.read(key +
".type", tensor);
822 if (tensor.item<int64_t>() !=
824 throw std::runtime_error(
"activation mismatch");
826 archive.read(key +
".tau", tensor);
827 this->
options_.tau(tensor.item<
double>());
828 archive.read(key +
".dim", tensor);
829 this->
options_.dim(tensor.item<
int>());
830 archive.read(key +
".hard", tensor);
831 this->
options_.hard(tensor.item<
bool>());
837 torch::nn::functional::GumbelSoftmaxFuncOptions
options_;
852 torch::nn::functional::HardshrinkFuncOptions().lambda(lambda)) {}
859 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
860 return torch::nn::functional::hardshrink(input,
options_);
865 inline const torch::nn::functional::HardshrinkFuncOptions &
options()
const {
871 inline torch::nn::functional::HardshrinkFuncOptions &
options() {
880 <<
"(\n lambda=" <<
options_.lambda() <<
"\n)";
888 inline torch::serialize::OutputArchive &
889 write(torch::serialize::OutputArchive &archive,
890 const std::string &key =
"hardshrink")
const override {
891 archive.write(key +
".type", torch::full({1},
static_cast<int64_t
>(
893 archive.write(key +
".lambda",
894 torch::full({1}, (double)this->
options_.lambda()));
904 inline torch::serialize::InputArchive &
905 read(torch::serialize::InputArchive &archive,
906 const std::string &key =
"hardshrink")
override {
907 torch::Tensor tensor;
909 archive.read(key +
".type", tensor);
911 throw std::runtime_error(
"activation mismatch");
913 archive.read(key +
".lambda", tensor);
914 this->
options_.lambda(tensor.item<
double>());
920 torch::nn::functional::HardshrinkFuncOptions
options_;
942 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
943 return torch::hardsigmoid(input);
958 inline torch::serialize::OutputArchive &
959 write(torch::serialize::OutputArchive &archive,
960 const std::string &key =
"hardsigmoid")
const override {
973 inline torch::serialize::InputArchive &
974 read(torch::serialize::InputArchive &archive,
975 const std::string &key =
"hardsigmoid")
override {
976 torch::Tensor tensor;
978 archive.read(key +
".type", tensor);
980 throw std::runtime_error(
"activation mismatch");
1005 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
1006 return torch::hardswish(input);
1021 inline torch::serialize::OutputArchive &
1022 write(torch::serialize::OutputArchive &archive,
1023 const std::string &key =
"hardswish")
const override {
1024 archive.write(key +
".type", torch::full({1},
static_cast<int64_t
>(
1035 inline torch::serialize::InputArchive &
1036 read(torch::serialize::InputArchive &archive,
1037 const std::string &key =
"hardswish")
override {
1038 torch::Tensor tensor;
1040 archive.read(key +
".type", tensor);
1042 throw std::runtime_error(
"activation mismatch");
1063 const torch::nn::functional::HardtanhFuncOptions &
options = {})
1070 explicit Hardtanh(
double min_val,
double max_val,
bool inplace =
false)
1074 .inplace(inplace)) {}
1081 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
1082 return torch::nn::functional::hardtanh(input,
options_);
1087 inline const torch::nn::functional::HardtanhFuncOptions &
options()
const {
1093 inline torch::nn::functional::HardtanhFuncOptions &
options() {
1102 <<
"(\n min_val=" <<
options_.min_val()
1103 <<
", max_val=" <<
options_.max_val()
1104 <<
", inplace=" <<
options_.inplace() <<
"\n)";
1112 inline torch::serialize::OutputArchive &
1113 write(torch::serialize::OutputArchive &archive,
1114 const std::string &key =
"hardtanh")
const override {
1115 archive.write(key +
".type",
1117 archive.write(key +
".min_val",
1118 torch::full({1}, (double)this->
options_.min_val()));
1119 archive.write(key +
".max_val",
1120 torch::full({1}, (double)this->
options_.max_val()));
1121 archive.write(key +
".inplace",
1122 torch::full({1}, (bool)this->
options_.inplace()));
1132 inline torch::serialize::InputArchive &
1133 read(torch::serialize::InputArchive &archive,
1134 const std::string &key =
"hardtanh")
override {
1135 torch::Tensor tensor;
1137 archive.read(key +
".type", tensor);
1139 throw std::runtime_error(
"activation mismatch");
1141 archive.read(key +
".min_val", tensor);
1142 this->
options_.min_val(tensor.item<
double>());
1143 archive.read(key +
".max_val", tensor);
1144 this->
options_.max_val(tensor.item<
double>());
1145 archive.read(key +
".inplace", tensor);
1146 this->
options_.inplace(tensor.item<
bool>());
1164 torch::nn::functional::InstanceNormFuncOptions
options = {})
1176 const torch::Tensor &running_var,
1177 const torch::Tensor &weight,
const torch::Tensor &bias,
1178 double eps,
double momentum,
1179 bool use_input_stats =
true)
1181 .running_mean(running_mean)
1182 .running_var(running_var)
1187 .use_input_stats(use_input_stats)) {}
1194 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
1195 return torch::nn::functional::instance_norm(input,
options_);
1200 inline const torch::nn::functional::InstanceNormFuncOptions &
options()
const {
1206 inline torch::nn::functional::InstanceNormFuncOptions &
options() {
1215 <<
", momentum=" <<
options_.momentum()
1216 <<
", use_input_stats=" <<
options_.use_input_stats();
1219 os <<
"\n running_mean = " <<
options_.running_mean()
1220 <<
"\n running_var = " <<
options_.running_var()
1221 <<
"\n weight = " <<
options_.weight()
1222 <<
"\n bias = " <<
options_.bias();
1233 inline torch::serialize::OutputArchive &
1234 write(torch::serialize::OutputArchive &archive,
1235 const std::string &key =
"instance_norm")
const override {
1239 archive.write(key +
".running_mean", this->
options_.running_mean());
1240 archive.write(key +
".var", this->
options_.running_var());
1241 archive.write(key +
".weight", this->
options_.weight());
1242 archive.write(key +
".bias", this->
options_.bias());
1243 archive.write(key +
".eps", torch::full({1}, (double)this->
options_.eps()));
1244 archive.write(key +
".momentum",
1245 torch::full({1}, (double)this->
options_.momentum()));
1246 archive.write(key +
".use_input_stats",
1247 torch::full({1}, (bool)this->
options_.use_input_stats()));
1257 inline torch::serialize::InputArchive &
1258 read(torch::serialize::InputArchive &archive,
1259 const std::string &key =
"instance_norm")
override {
1260 torch::Tensor tensor;
1262 archive.read(key +
".type", tensor);
1263 if (tensor.item<int64_t>() !=
1265 throw std::runtime_error(
"activation mismatch");
1267 archive.read(key +
".running_mean", this->
options_.running_mean());
1268 archive.read(key +
".running_var", this->
options_.running_var());
1269 archive.read(key +
".weight", this->
options_.weight());
1270 archive.read(key +
".bias", this->
options_.bias());
1271 archive.read(key +
".eps", tensor);
1272 this->
options_.eps(tensor.item<
double>());
1273 archive.read(key +
".momentum", tensor);
1274 this->
options_.momentum(tensor.item<
double>());
1275 archive.read(key +
".use_input_stats", tensor);
1276 this->
options_.use_input_stats(tensor.item<
bool>());
1282 torch::nn::functional::InstanceNormFuncOptions
options_;
1294 std::move(normalized_shape))) {}
1307 const torch::Tensor &weight,
const torch::Tensor &bias,
1310 std::move(normalized_shape))
1320 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
1321 return torch::nn::functional::layer_norm(input,
options_);
1326 inline const torch::nn::functional::LayerNormFuncOptions &
options()
const {
1332 inline torch::nn::functional::LayerNormFuncOptions &
options() {
1342 os <<
"\n normalized_shape = " <<
options_.normalized_shape()
1343 <<
"\n weight = " <<
options_.weight()
1344 <<
"\n bias = " <<
options_.bias();
1355 inline torch::serialize::OutputArchive &
1356 write(torch::serialize::OutputArchive &archive,
1357 const std::string &key =
"layer_norm")
const override {
1358 archive.write(key +
".type", torch::full({1},
static_cast<int64_t
>(
1360 archive.write(key +
".weight", this->
options_.weight());
1361 archive.write(key +
".bias", this->
options_.bias());
1362 archive.write(key +
".eps", torch::full({1}, (double)this->
options_.eps()));
1372 inline torch::serialize::InputArchive &
1373 read(torch::serialize::InputArchive &archive,
1374 const std::string &key =
"layer_norm")
override {
1375 torch::Tensor tensor;
1377 archive.read(key +
".type", tensor);
1379 throw std::runtime_error(
"activation mismatch");
1381 archive.read(key +
".weight", this->
options_.weight());
1382 archive.read(key +
".bias", this->
options_.bias());
1383 archive.read(key +
".eps", tensor);
1384 this->
options_.eps(tensor.item<
double>());
1412 explicit LeakyReLU(
double negative_slope,
bool inplace =
false)
1414 .negative_slope(negative_slope)
1415 .inplace(inplace)) {}
1422 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
1423 return torch::nn::functional::leaky_relu(input,
options_);
1428 inline const torch::nn::functional::LeakyReLUFuncOptions &
options()
const {
1434 inline torch::nn::functional::LeakyReLUFuncOptions &
options() {
1442 <<
"(\n negative_slope=" <<
options_.negative_slope()
1443 <<
", inplace=" <<
options_.inplace() <<
"\n)";
1451 inline torch::serialize::OutputArchive &
1452 write(torch::serialize::OutputArchive &archive,
1453 const std::string &key =
"leaky_relu")
const override {
1454 archive.write(key +
".type", torch::full({1},
static_cast<int64_t
>(
1457 archive.write(key +
".negative_slope",
1458 torch::full({1}, (double)this->
options_.negative_slope()));
1459 archive.write(key +
".inplace",
1460 torch::full({1}, (bool)this->
options_.inplace()));
1470 inline torch::serialize::InputArchive &
1471 read(torch::serialize::InputArchive &archive,
1472 const std::string &key =
"leaky_relu")
override {
1473 torch::Tensor tensor;
1475 archive.read(key +
".type", tensor);
1477 throw std::runtime_error(
"activation mismatch");
1479 archive.read(key +
".negative_slope", tensor);
1480 this->
options_.negative_slope(tensor.item<
double>());
1481 archive.read(key +
".inplace", tensor);
1482 this->
options_.inplace(tensor.item<
bool>());
1497 :
options_(
torch::nn::functional::LocalResponseNormFuncOptions(size)) {}
1502 const torch::nn::functional::LocalResponseNormFuncOptions &
options)
1511 :
options_(
torch::nn::functional::LocalResponseNormFuncOptions(size)
1521 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
1522 return torch::nn::functional::local_response_norm(input,
options_);
1527 inline const torch::nn::functional::LocalResponseNormFuncOptions &
1534 inline torch::nn::functional::LocalResponseNormFuncOptions &
options() {
1543 <<
", k=" <<
options_.k() <<
"\n)";
1551 inline torch::serialize::OutputArchive &
1552 write(torch::serialize::OutputArchive &archive,
1553 const std::string &key =
"local_response_norm")
const override {
1554 archive.write(key +
".type",
1555 torch::full({1},
static_cast<int64_t
>(
1558 archive.write(key +
".size",
1559 torch::full({1}, (int64_t)this->
options_.size()));
1560 archive.write(key +
".alpha",
1561 torch::full({1}, (double)this->
options_.alpha()));
1562 archive.write(key +
".beta",
1563 torch::full({1}, (double)this->
options_.beta()));
1564 archive.write(key +
".k", torch::full({1}, (double)this->
options_.k()));
1574 inline torch::serialize::InputArchive &
1575 read(torch::serialize::InputArchive &archive,
1576 const std::string &key =
"local_response_norm")
override {
1577 torch::Tensor tensor;
1579 archive.read(key +
".type", tensor);
1580 if (tensor.item<int64_t>() !=
1582 throw std::runtime_error(
"activation mismatch");
1584 archive.read(key +
".size", tensor);
1585 this->
options_.size(tensor.item<int64_t>());
1586 archive.read(key +
".alpha", tensor);
1587 this->
options_.alpha(tensor.item<
double>());
1588 archive.read(key +
".beta", tensor);
1589 this->
options_.beta(tensor.item<
double>());
1590 archive.read(key +
".k", tensor);
1591 this->
options_.k(tensor.item<
double>());
1597 torch::nn::functional::LocalResponseNormFuncOptions
options_;
1614 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
1615 return torch::log_sigmoid(input);
1629 inline torch::serialize::OutputArchive &
1630 write(torch::serialize::OutputArchive &archive,
1631 const std::string &key =
"logsigmoid")
const override {
1632 archive.write(key +
".type", torch::full({1},
static_cast<int64_t
>(
1643 inline torch::serialize::InputArchive &
1644 read(torch::serialize::InputArchive &archive,
1645 const std::string &key =
"logsigmoid")
override {
1646 torch::Tensor tensor;
1648 archive.read(key +
".type", tensor);
1650 throw std::runtime_error(
"activation mismatch");
1669 :
options_(
torch::nn::functional::LogSoftmaxFuncOptions(dim)) {}
1674 const torch::nn::functional::LogSoftmaxFuncOptions &
options)
1682 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
1683 return torch::nn::functional::log_softmax(input,
options_);
1688 inline const torch::nn::functional::LogSoftmaxFuncOptions &
options()
const {
1694 inline torch::nn::functional::LogSoftmaxFuncOptions &
options() {
1710 inline torch::serialize::OutputArchive &
1711 write(torch::serialize::OutputArchive &archive,
1712 const std::string &key =
"logsoftmax")
const override {
1713 archive.write(key +
".type", torch::full({1},
static_cast<int64_t
>(
1724 inline torch::serialize::InputArchive &
1725 read(torch::serialize::InputArchive &archive,
1726 const std::string &key =
"logsoftmax")
override {
1727 torch::Tensor tensor;
1729 archive.read(key +
".type", tensor);
1731 throw std::runtime_error(
"activation mismatch");
1754 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
1755 return torch::mish(input);
1769 inline torch::serialize::OutputArchive &
1770 write(torch::serialize::OutputArchive &archive,
1771 const std::string &key =
"mish")
const override {
1772 archive.write(key +
".type",
1783 inline torch::serialize::InputArchive &
1784 read(torch::serialize::InputArchive &archive,
1785 const std::string &key =
"mish")
override {
1786 torch::Tensor tensor;
1788 archive.read(key +
".type", tensor);
1790 throw std::runtime_error(
"activation mismatch");
1810 torch::nn::functional::NormalizeFuncOptions().p(p).eps(eps).dim(
1818 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
1819 return torch::nn::functional::normalize(input,
options_);
1824 inline const torch::nn::functional::NormalizeFuncOptions &
options()
const {
1830 inline torch::nn::functional::NormalizeFuncOptions &
options() {
1846 inline torch::serialize::OutputArchive &
1847 write(torch::serialize::OutputArchive &archive,
1848 const std::string &key =
"normalize")
const override {
1849 archive.write(key +
".type", torch::full({1},
static_cast<int64_t
>(
1851 archive.write(key +
".p", torch::full({1}, (double)this->
options_.p()));
1852 archive.write(key +
".eps", torch::full({1}, (double)this->
options_.eps()));
1853 archive.write(key +
".dim",
1854 torch::full({1}, (int64_t)this->
options_.dim()));
1864 inline torch::serialize::InputArchive &
1865 read(torch::serialize::InputArchive &archive,
1866 const std::string &key =
"normalize")
override {
1867 torch::Tensor tensor;
1869 archive.read(key +
".type", tensor);
1871 throw std::runtime_error(
"activation mismatch");
1873 archive.read(key +
".p", tensor);
1874 this->
options_.p(tensor.item<
double>());
1875 archive.read(key +
".eps", tensor);
1876 this->
options_.eps(tensor.item<
double>());
1877 archive.read(key +
".dim", tensor);
1878 this->
options_.dim(tensor.item<int64_t>());
1907 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
1908 return torch::nn::functional::prelu(input,
weight());
1917 os <<
"(\n weight = " <<
weight() <<
"\n)";
1925 inline torch::serialize::OutputArchive &
1926 write(torch::serialize::OutputArchive &archive,
1927 const std::string &key =
"prelu")
const override {
1928 archive.write(key +
".type",
1930 archive.write(key +
".weight", this->
weight());
1940 inline torch::serialize::InputArchive &
1941 read(torch::serialize::InputArchive &archive,
1942 const std::string &key =
"prelu")
override {
1943 torch::Tensor tensor;
1945 archive.read(key +
".type", tensor);
1947 throw std::runtime_error(
"activation mismatch");
1949 archive.read(key +
".weight", this->
weight());
1973 :
options_(
torch::nn::functional::ReLUFuncOptions().inplace(inplace)) {}
1980 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
1981 return torch::nn::functional::relu(input,
options_);
1986 inline const torch::nn::functional::ReLUFuncOptions &
options()
const {
1998 <<
"(\n inplace=" <<
options_.inplace() <<
"\n)";
2006 inline torch::serialize::OutputArchive &
2007 write(torch::serialize::OutputArchive &archive,
2008 const std::string &key =
"relu")
const override {
2009 archive.write(key +
".type",
2011 archive.write(key +
".inplace",
2012 torch::full({1}, (bool)this->
options_.inplace()));
2022 inline torch::serialize::InputArchive &
2023 read(torch::serialize::InputArchive &archive,
2024 const std::string &key =
"relu")
override {
2025 torch::Tensor tensor;
2027 archive.read(key +
".type", tensor);
2029 throw std::runtime_error(
"activation mismatch");
2031 archive.read(key +
".inplace", tensor);
2032 this->
options_.inplace(tensor.item<
bool>());
2056 :
options_(
torch::nn::functional::ReLU6FuncOptions().inplace(inplace)) {}
2063 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
2064 return torch::nn::functional::relu6(input,
options_);
2069 inline const torch::nn::functional::ReLU6FuncOptions &
options()
const {
2081 <<
"(\n inplace=" <<
options_.inplace() <<
"\n)";
2089 inline torch::serialize::OutputArchive &
2090 write(torch::serialize::OutputArchive &archive,
2091 const std::string &key =
"relu6")
const override {
2092 archive.write(key +
".type",
2094 archive.write(key +
".inplace",
2095 torch::full({1}, (bool)this->
options_.inplace()));
2105 inline torch::serialize::InputArchive &
2106 read(torch::serialize::InputArchive &archive,
2107 const std::string &key =
"relu6")
override {
2108 torch::Tensor tensor;
2110 archive.read(key +
".type", tensor);
2112 throw std::runtime_error(
"activation mismatch");
2114 archive.read(key +
".inplace", tensor);
2115 this->
options_.inplace(tensor.item<
bool>());
2137 explicit RReLU(
const torch::nn::functional::RReLUFuncOptions &
options = {})
2144 explicit RReLU(
double lower,
double upper,
bool inplace =
false)
2148 .inplace(inplace)) {}
2155 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
2156 return torch::nn::functional::rrelu(input,
options_);
2161 inline const torch::nn::functional::RReLUFuncOptions &
options()
const {
2182 inline torch::serialize::OutputArchive &
2183 write(torch::serialize::OutputArchive &archive,
2184 const std::string &key =
"rrelu")
const override {
2185 archive.write(key +
".type",
2187 archive.write(key +
".lower",
2188 torch::full({1}, (double)this->
options_.lower()));
2189 archive.write(key +
".upper",
2190 torch::full({1}, (double)this->
options_.upper()));
2191 archive.write(key +
".inplace",
2192 torch::full({1}, (bool)this->
options_.inplace()));
2202 inline torch::serialize::InputArchive &
2203 read(torch::serialize::InputArchive &archive,
2204 const std::string &key =
"rrelu")
override {
2205 torch::Tensor tensor;
2207 archive.read(key +
".type", tensor);
2209 throw std::runtime_error(
"activation mismatch");
2211 archive.read(key +
".lower", tensor);
2212 this->
options_.lower(tensor.item<
double>());
2213 archive.read(key +
".upper", tensor);
2214 this->
options_.upper(tensor.item<
double>());
2215 archive.read(key +
".inplace", tensor);
2216 this->
options_.inplace(tensor.item<
bool>());
2243 :
options_(
torch::nn::functional::SELUFuncOptions().inplace(inplace)) {}
2250 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
2251 return torch::nn::functional::selu(input,
options_);
2256 inline const torch::nn::functional::SELUFuncOptions &
options()
const {
2268 <<
"(\n inplace=" <<
options_.inplace() <<
"\n)";
2276 inline torch::serialize::OutputArchive &
2277 write(torch::serialize::OutputArchive &archive,
2278 const std::string &key =
"selu")
const override {
2279 archive.write(key +
".type",
2281 archive.write(key +
".inplace",
2282 torch::full({1}, (bool)this->
options_.inplace()));
2292 inline torch::serialize::InputArchive &
2293 read(torch::serialize::InputArchive &archive,
2294 const std::string &key =
"selu")
override {
2295 torch::Tensor tensor;
2297 archive.read(key +
".type", tensor);
2299 throw std::runtime_error(
"activation mismatch");
2301 archive.read(key +
".inplace", tensor);
2302 this->
options_.inplace(tensor.item<
bool>());
2321 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
2322 return torch::sigmoid(input);
2336 inline torch::serialize::OutputArchive &
2337 write(torch::serialize::OutputArchive &archive,
2338 const std::string &key =
"sigmoid")
const override {
2339 archive.write(key +
".type",
2350 inline torch::serialize::InputArchive &
2351 read(torch::serialize::InputArchive &archive,
2352 const std::string &key =
"sigmoid")
override {
2353 torch::Tensor tensor;
2355 archive.read(key +
".type", tensor);
2357 throw std::runtime_error(
"activation mismatch");
2373 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
2374 return torch::silu(input);
2388 inline torch::serialize::OutputArchive &
2389 write(torch::serialize::OutputArchive &archive,
2390 const std::string &key =
"silu")
const override {
2391 archive.write(key +
".type",
2402 inline torch::serialize::InputArchive &
2403 read(torch::serialize::InputArchive &archive,
2404 const std::string &key =
"silu")
override {
2405 torch::Tensor tensor;
2407 archive.read(key +
".type", tensor);
2409 throw std::runtime_error(
"activation mismatch");
2427 :
options_(
torch::nn::functional::SoftmaxFuncOptions(dim)) {}
2439 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
2440 return torch::nn::functional::softmax(input,
options_);
2445 inline const torch::nn::functional::SoftmaxFuncOptions &
options()
const {
2451 inline torch::nn::functional::SoftmaxFuncOptions &
options() {
2467 inline torch::serialize::OutputArchive &
2468 write(torch::serialize::OutputArchive &archive,
2469 const std::string &key =
"softmax")
const override {
2470 archive.write(key +
".type",
2472 archive.write(key +
".dim",
2473 torch::full({1}, (int64_t)this->
options_.dim()));
2483 inline torch::serialize::InputArchive &
2484 read(torch::serialize::InputArchive &archive,
2485 const std::string &key =
"softmax")
override {
2486 torch::Tensor tensor;
2488 archive.read(key +
".type", tensor);
2490 throw std::runtime_error(
"activation mismatch");
2492 archive.read(key +
".dim", tensor);
2493 this->
options_.dim(tensor.item<int64_t>());
2512 :
options_(
torch::nn::functional::SoftminFuncOptions(dim)) {}
2524 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
2525 return torch::nn::functional::softmin(input,
options_);
2530 inline const torch::nn::functional::SoftminFuncOptions &
options()
const {
2536 inline torch::nn::functional::SoftminFuncOptions &
options() {
2552 inline torch::serialize::OutputArchive &
2553 write(torch::serialize::OutputArchive &archive,
2554 const std::string &key =
"softmin")
const override {
2555 archive.write(key +
".type",
2557 archive.write(key +
".dim",
2558 torch::full({1}, (int64_t)this->
options_.dim()));
2568 inline torch::serialize::InputArchive &
2569 read(torch::serialize::InputArchive &archive,
2570 const std::string &key =
"softmin")
override {
2571 torch::Tensor tensor;
2573 archive.read(key +
".type", tensor);
2575 throw std::runtime_error(
"activation mismatch");
2577 archive.read(key +
".dim", tensor);
2578 this->
options_.dim(tensor.item<int64_t>());
2604 torch::nn::functional::SoftplusFuncOptions().beta(beta).
threshold(
2612 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
2613 return torch::nn::functional::softplus(input,
options_);
2618 inline const torch::nn::functional::SoftplusFuncOptions &
options()
const {
2624 inline torch::nn::functional::SoftplusFuncOptions &
options() {
2632 <<
", theshold=" <<
options_.threshold() <<
"\n)";
2640 inline torch::serialize::OutputArchive &
2641 write(torch::serialize::OutputArchive &archive,
2642 const std::string &key =
"softplus")
const override {
2643 archive.write(key +
".type",
2645 archive.write(key +
".beta",
2646 torch::full({1}, (double)this->
options_.beta()));
2647 archive.write(key +
".threshold",
2648 torch::full({1}, (double)this->
options_.threshold()));
2658 inline torch::serialize::InputArchive &
2659 read(torch::serialize::InputArchive &archive,
2660 const std::string &key =
"softplus")
override {
2661 torch::Tensor tensor;
2663 archive.read(key +
".type", tensor);
2665 throw std::runtime_error(
"activation mismatch");
2667 archive.read(key +
".beta", tensor);
2668 this->
options_.beta(tensor.item<
double>());
2669 archive.read(key +
".threshold", tensor);
2670 this->
options_.threshold(tensor.item<
double>());
2700 torch::nn::functional::SoftshrinkFuncOptions().lambda(lambda)) {}
2707 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
2708 return torch::nn::functional::softshrink(input,
options_);
2713 inline const torch::nn::functional::SoftshrinkFuncOptions &
options()
const {
2719 inline torch::nn::functional::SoftshrinkFuncOptions &
options() {
2727 <<
"(\n lambda=" <<
options_.lambda() <<
"\n)";
2735 inline torch::serialize::OutputArchive &
2736 write(torch::serialize::OutputArchive &archive,
2737 const std::string &key =
"softshrink")
const override {
2738 archive.write(key +
".type", torch::full({1},
static_cast<int64_t
>(
2740 archive.write(key +
".lambda",
2741 torch::full({1}, (double)this->
options_.lambda()));
2751 inline torch::serialize::InputArchive &
2752 read(torch::serialize::InputArchive &archive,
2753 const std::string &key =
"softshrink")
override {
2754 torch::Tensor tensor;
2756 archive.read(key +
".type", tensor);
2758 throw std::runtime_error(
"activation mismatch");
2760 archive.read(key +
".lambda", tensor);
2761 this->
options_.lambda(tensor.item<
double>());
2780 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
2781 return torch::nn::functional::softsign(input);
2795 inline torch::serialize::OutputArchive &
2796 write(torch::serialize::OutputArchive &archive,
2797 const std::string &key =
"softsign")
const override {
2798 archive.write(key +
".type",
2809 inline torch::serialize::InputArchive &
2810 read(torch::serialize::InputArchive &archive,
2811 const std::string &key =
"softsign")
override {
2812 torch::Tensor tensor;
2814 archive.read(key +
".type", tensor);
2816 throw std::runtime_error(
"activation mismatch");
2832 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
2833 return torch::tanh(input);
2847 inline torch::serialize::OutputArchive &
2848 write(torch::serialize::OutputArchive &archive,
2849 const std::string &key =
"tanh")
const override {
2850 archive.write(key +
".type",
2861 inline torch::serialize::InputArchive &
2862 read(torch::serialize::InputArchive &archive,
2863 const std::string &key =
"tanh")
override {
2864 torch::Tensor tensor;
2866 archive.read(key +
".type", tensor);
2868 throw std::runtime_error(
"activation mismatch");
2884 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
2885 return torch::nn::functional::tanhshrink(input);
2899 inline torch::serialize::OutputArchive &
2900 write(torch::serialize::OutputArchive &archive,
2901 const std::string &key =
"tanhshrink")
const override {
2902 archive.write(key +
".type", torch::full({1},
static_cast<int64_t
>(
2913 inline torch::serialize::InputArchive &
2914 read(torch::serialize::InputArchive &archive,
2915 const std::string &key =
"tanhshrink")
override {
2916 torch::Tensor tensor;
2918 archive.read(key +
".type", tensor);
2920 throw std::runtime_error(
"activation mismatch");
2948 .inplace(inplace)) {}
2955 inline torch::Tensor
apply(
const torch::Tensor &input)
const override {
2956 return torch::nn::functional::threshold(input,
options_);
2961 inline const torch::nn::functional::ThresholdFuncOptions &
options()
const {
2967 inline torch::nn::functional::ThresholdFuncOptions &
options() {
2975 <<
"(\n threshold=" <<
options_.threshold()
2985 inline torch::serialize::OutputArchive &
2986 write(torch::serialize::OutputArchive &archive,
2987 const std::string &key =
"threshold")
const override {
2988 archive.write(key +
".type", torch::full({1},
static_cast<int64_t
>(
2990 archive.write(key +
".threshold",
2991 torch::full({1}, this->
options_.threshold()));
2992 archive.write(key +
".value", torch::full({1}, this->
options_.value()));
2993 archive.write(key +
".inplace", torch::full({1}, this->
options_.inplace()));
3003 inline torch::serialize::InputArchive &
3004 read(torch::serialize::InputArchive &archive,
3005 const std::string &key =
"threshold")
override {
3006 torch::Tensor tensor;
3008 archive.read(key +
".type", tensor);
3010 throw std::runtime_error(
"activation mismatch");
3012 archive.read(key +
".threshold", tensor);
3013 this->
options_.threshold(tensor.item<
double>());
3014 archive.read(key +
".value", tensor);
3015 this->
options_.value(tensor.item<
double>());
3016 archive.read(key +
".inplace", tensor);
3017 this->
options_.inplace(tensor.item<
bool>());
Abstract activation function structure.
Definition activation.hpp:65
~ActivationFunction() override=default
void pretty_print(std::ostream &os) const noexcept override=0
Returns a string representation of the activation function.
virtual torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key) const =0
Writes the activation function into a torch::serialize::OutputArchive object.
virtual torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key)=0
Reads the activation function from a torch::serialize::InputArchive object.
virtual torch::Tensor apply(const torch::Tensor &input) const =0
Applies the activation function to the given input.
Batch Normalization as described in the paper.
Definition activation.hpp:159
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:230
torch::Tensor & running_mean()
Returns non-constant reference to running mean.
Definition activation.hpp:206
torch::Tensor running_var_
Definition activation.hpp:307
const torch::Tensor & running_mean() const
Returns constant reference to running mean.
Definition activation.hpp:202
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="batch_norm") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:256
const torch::Tensor & running_var() const
Returns constant reference to running variance.
Definition activation.hpp:210
torch::Tensor running_mean_
Definition activation.hpp:307
const torch::nn::functional::BatchNormFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:218
~BatchNorm() override=default
BatchNorm(torch::Tensor running_mean, torch::Tensor running_var, const torch::Tensor &weight, const torch::Tensor &bias, double eps, double momentum, bool training=false)
Provides the BatchNorm operation.
Definition activation.hpp:178
torch::nn::functional::BatchNormFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:224
torch::Tensor & running_var()
Returns non-constant reference to running var.
Definition activation.hpp:214
torch::nn::functional::BatchNormFuncOptions options_
Definition activation.hpp:306
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="batch_norm") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:283
BatchNorm(torch::Tensor running_mean, torch::Tensor running_var, torch::nn::functional::BatchNormFuncOptions options={})
Provides the BatchNorm operation.
Definition activation.hpp:165
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:195
Continuously Differentiable Exponential Linear Units activation function.
Definition activation.hpp:316
torch::nn::functional::CELUFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:347
CELU(torch::nn::functional::CELUFuncOptions options={})
Provides the CELU operation.
Definition activation.hpp:320
torch::nn::functional::CELUFuncOptions options_
Definition activation.hpp:397
const torch::nn::functional::CELUFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:341
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="celu") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:380
CELU(double alpha, bool inplace=false)
Provides the CELU operation.
Definition activation.hpp:326
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:351
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:335
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="celu") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:362
Exponential Linear Units activation function.
Definition activation.hpp:409
const torch::nn::functional::ELUFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:434
torch::nn::functional::ELUFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:440
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="elu") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:456
ELU(double alpha, bool inplace=false)
Provides the ELU operation.
Definition activation.hpp:419
void pretty_print(std::ostream &os=Log(log::info)) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:445
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:428
torch::nn::functional::ELUFuncOptions options_
Definition activation.hpp:491
ELU(torch::nn::functional::ELUFuncOptions options={})
Provides the ELU operation.
Definition activation.hpp:413
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="elu") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:474
Gaussian Error Linear Units activation function.
Definition activation.hpp:502
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="gelu") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:527
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:517
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:511
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="gelu") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:541
Grated Linear Units activation function.
Definition activation.hpp:562
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="glu") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:622
const torch::nn::functional::GLUFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:585
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:579
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="glu") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:606
torch::nn::functional::GLUFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:591
torch::nn::functional::GLUFuncOptions options_
Definition activation.hpp:637
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:595
GLU(torch::nn::functional::GLUFuncOptions options={})
Provides the GLU operation.
Definition activation.hpp:566
GLU(int64_t dim)
Provides the GLU operation.
Definition activation.hpp:571
Group Normalization over a mini-batch of inputs as described in the paper Group Normalization,...
Definition activation.hpp:642
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:671
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="group_norm") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:724
torch::nn::functional::GroupNormFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:683
const torch::nn::functional::GroupNormFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:677
~GroupNorm() override=default
GroupNorm(int64_t num_groups, const torch::Tensor &weight, const torch::Tensor &bias, double eps)
Provides the GroupNorm operation.
Definition activation.hpp:659
GroupNorm(int64_t num_groups)
Provides the GroupNorm operation.
Definition activation.hpp:646
void pretty_print(std::ostream &os=Log(log::info)) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:690
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="group_norm") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:707
torch::nn::functional::GroupNormFuncOptions options_
Definition activation.hpp:741
GroupNorm(torch::nn::functional::GroupNormFuncOptions options)
Provides the GroupNorm operation.
Definition activation.hpp:651
Gumbel-Softmax distribution activation function.
Definition activation.hpp:745
const torch::nn::functional::GumbelSoftmaxFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:775
GumbelSoftmax(torch::nn::functional::GumbelSoftmaxFuncOptions options={})
Provides the GumbelSoftmax operation.
Definition activation.hpp:749
~GumbelSoftmax() override=default
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:768
torch::nn::functional::GumbelSoftmaxFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:781
void pretty_print(std::ostream &os=Log(log::info)) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:788
GumbelSoftmax(double tau, int dim, bool hard)
Provides the GumbelSoftmax operation.
Definition activation.hpp:757
torch::nn::functional::GumbelSoftmaxFuncOptions options_
Definition activation.hpp:837
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="gumbel_softmax") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:799
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="gumbel_softmax") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:817
Hard shrinkish activation function.
Definition activation.hpp:841
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="hardshrink") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:905
void pretty_print(std::ostream &os=Log(log::info)) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:878
~Hardshrink() override=default
torch::nn::functional::HardshrinkFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:871
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="hardshrink") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:889
Hardshrink(double lambda)
Provides the Hardshrink operation.
Definition activation.hpp:850
torch::nn::functional::HardshrinkFuncOptions options_
Definition activation.hpp:920
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:859
Hardshrink(torch::nn::functional::HardshrinkFuncOptions options={})
Provides the Hardshrink operation.
Definition activation.hpp:845
const torch::nn::functional::HardshrinkFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:865
Hardsigmoid activation function.
Definition activation.hpp:933
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:942
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="hardsigmoid") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:974
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="hardsigmoid") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:959
void pretty_print(std::ostream &os=Log(log::info)) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:949
~Hardsigmoid() override=default
Hardswish activation function.
Definition activation.hpp:996
~Hardswish() override=default
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="hardswish") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:1022
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:1005
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="hardswish") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:1036
void pretty_print(std::ostream &os=Log(log::info)) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:1012
Hardtanh activation function.
Definition activation.hpp:1058
const torch::nn::functional::HardtanhFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:1087
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="hardtanh") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:1133
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:1081
Hardtanh(const torch::nn::functional::HardtanhFuncOptions &options={})
Provides the Hardtanh operation.
Definition activation.hpp:1062
torch::nn::functional::HardtanhFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:1093
~Hardtanh() override=default
Hardtanh(double min_val, double max_val, bool inplace=false)
Provides the Hardtanh operation.
Definition activation.hpp:1070
torch::nn::functional::HardtanhFuncOptions options_
Definition activation.hpp:1152
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="hardtanh") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:1113
void pretty_print(std::ostream &os=Log(log::info)) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:1100
Instance Normalization as described in the paper.
Definition activation.hpp:1159
void pretty_print(std::ostream &os=Log(log::info)) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:1213
torch::nn::functional::InstanceNormFuncOptions options_
Definition activation.hpp:1282
torch::nn::functional::InstanceNormFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:1206
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:1194
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="instance_norm") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:1234
const torch::nn::functional::InstanceNormFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:1200
InstanceNorm(torch::nn::functional::InstanceNormFuncOptions options={})
Provides the InstanceNorm operation.
Definition activation.hpp:1163
InstanceNorm(const torch::Tensor &running_mean, const torch::Tensor &running_var, const torch::Tensor &weight, const torch::Tensor &bias, double eps, double momentum, bool use_input_stats=true)
Provides the InstanceNorm operation.
Definition activation.hpp:1175
~InstanceNorm() override=default
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="instance_norm") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:1258
Layer Normalization as described in the paper.
Definition activation.hpp:1288
const torch::nn::functional::LayerNormFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:1326
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="layer_norm") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:1356
LayerNorm(std::vector< int64_t > normalized_shape, const torch::Tensor &weight, const torch::Tensor &bias, double eps)
Provides the LayerNorm operation.
Definition activation.hpp:1306
LayerNorm(std::vector< int64_t > normalized_shape)
Provides the LayerNorm operation.
Definition activation.hpp:1292
~LayerNorm() override=default
torch::nn::functional::LayerNormFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:1332
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:1338
LayerNorm(torch::nn::functional::LayerNormFuncOptions options)
Provides the LayerNorm operation.
Definition activation.hpp:1298
torch::nn::functional::LayerNormFuncOptions options_
Definition activation.hpp:1390
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:1320
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="layer_norm") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:1373
Leaky ReLU activation function.
Definition activation.hpp:1402
~LeakyReLU() override=default
const torch::nn::functional::LeakyReLUFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:1428
LeakyReLU(torch::nn::functional::LeakyReLUFuncOptions options={})
Provides the LeakyReLU operation.
Definition activation.hpp:1406
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="leaky_relu") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:1452
torch::nn::functional::LeakyReLUFuncOptions options_
Definition activation.hpp:1488
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:1422
torch::nn::functional::LeakyReLUFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:1434
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="leaky_relu") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:1471
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:1440
LeakyReLU(double negative_slope, bool inplace=false)
Provides the LeakyReLU operation.
Definition activation.hpp:1412
Local response Normalization.
Definition activation.hpp:1492
torch::nn::functional::LocalResponseNormFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:1534
LocalResponseNorm(const torch::nn::functional::LocalResponseNormFuncOptions &options)
Provides the LocalResponseNorm operation.
Definition activation.hpp:1501
torch::nn::functional::LocalResponseNormFuncOptions options_
Definition activation.hpp:1597
LocalResponseNorm(int64_t size, double alpha, double beta, double k)
Provides the LocalResponseNorm operation.
Definition activation.hpp:1510
LocalResponseNorm(int64_t size)
Provides the LocalResponseNorm operation.
Definition activation.hpp:1496
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="local_response_norm") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:1552
~LocalResponseNorm() override=default
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:1521
const torch::nn::functional::LocalResponseNormFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:1528
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:1540
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="local_response_norm") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:1575
LogSigmoid activation function.
Definition activation.hpp:1605
~LogSigmoid() override=default
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="logsigmoid") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:1644
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:1620
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="logsigmoid") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:1630
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:1614
LogSoftmax activation function.
Definition activation.hpp:1664
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:1682
torch::nn::functional::LogSoftmaxFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:1694
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="logsoftmax") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:1711
LogSoftmax(int64_t dim)
Provides the LogSoftmax operation.
Definition activation.hpp:1668
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:1700
LogSoftmax(const torch::nn::functional::LogSoftmaxFuncOptions &options)
Provides the LogSoftmax operation.
Definition activation.hpp:1673
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="logsoftmax") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:1725
torch::nn::functional::LogSoftmaxFuncOptions options_
Definition activation.hpp:1737
~LogSoftmax() override=default
const torch::nn::functional::LogSoftmaxFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:1688
Mish activation function.
Definition activation.hpp:1745
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:1754
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:1760
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="mish") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:1784
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="mish") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:1770
No-op activation function.
Definition activation.hpp:107
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="none") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:128
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:118
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:112
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="none") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:142
Lp Normalization.
Definition activation.hpp:1797
~Normalize() override=default
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="normalize") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:1847
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="normalize") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:1865
torch::nn::functional::NormalizeFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:1830
Normalize(double p, double eps, int64_t dim)
Provides the Normalize operation.
Definition activation.hpp:1808
Normalize(torch::nn::functional::NormalizeFuncOptions options={})
Provides the Normalize operation.
Definition activation.hpp:1801
torch::nn::functional::NormalizeFuncOptions options_
Definition activation.hpp:1884
const torch::nn::functional::NormalizeFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:1824
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:1818
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:1836
PReLU activation function.
Definition activation.hpp:1888
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:1907
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:1913
PReLU(torch::Tensor weight)
Provides the PReLU operation.
Definition activation.hpp:1892
torch::Tensor weight_
Definition activation.hpp:1955
~PReLU() override=default
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="prelu") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:1926
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="prelu") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:1941
const torch::Tensor & weight() const
Returns constant reference to weights.
Definition activation.hpp:1898
torch::Tensor & weight()
Returns non-constant reference to weights.
Definition activation.hpp:1902
Randomized ReLU activation function.
Definition activation.hpp:2133
RReLU(double lower, double upper, bool inplace=false)
Provides the RReLU operation.
Definition activation.hpp:2144
RReLU(const torch::nn::functional::RReLUFuncOptions &options={})
Provides the RReLU operation.
Definition activation.hpp:2137
const torch::nn::functional::RReLUFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:2161
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:2155
torch::nn::functional::RReLUFuncOptions options_
Definition activation.hpp:2222
~RReLU() override=default
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="rrelu") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:2203
torch::nn::functional::RReLUFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:2167
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:2171
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="rrelu") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:2183
ReLU6 activation function.
Definition activation.hpp:2046
~ReLU6() override=default
ReLU6(torch::nn::functional::ReLU6FuncOptions options={})
Provides the ReLU6 operation.
Definition activation.hpp:2050
torch::nn::functional::ReLU6FuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:2075
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:2063
const torch::nn::functional::ReLU6FuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:2069
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="relu6") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:2090
ReLU6(bool inplace)
Provides the ReLU6 operation.
Definition activation.hpp:2055
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:2079
torch::nn::functional::ReLU6FuncOptions options_
Definition activation.hpp:2121
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="relu6") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:2106
ReLU activation function.
Definition activation.hpp:1963
torch::nn::functional::ReLUFuncOptions options_
Definition activation.hpp:2038
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:1980
ReLU(bool inplace)
Provides the ReLU operation.
Definition activation.hpp:1972
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="relu") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:2007
torch::nn::functional::ReLUFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:1992
ReLU(torch::nn::functional::ReLUFuncOptions options={})
Provides the ReLU operation.
Definition activation.hpp:1967
const torch::nn::functional::ReLUFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:1986
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:1996
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="relu") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:2023
SELU activation function.
Definition activation.hpp:2233
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:2266
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="selu") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:2293
torch::nn::functional::SELUFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:2262
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:2250
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="selu") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:2277
const torch::nn::functional::SELUFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:2256
SELU(bool inplace)
Provides the SELU operation.
Definition activation.hpp:2242
SELU(torch::nn::functional::SELUFuncOptions options={})
Provides the SELU operation.
Definition activation.hpp:2237
torch::nn::functional::SELUFuncOptions options_
Definition activation.hpp:2308
Sigmoid Linear Unit activation function.
Definition activation.hpp:2368
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="silu") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:2389
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:2379
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:2373
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="silu") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:2403
Sigmoid activation function.
Definition activation.hpp:2316
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:2327
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:2321
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="sigmoid") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:2351
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="sigmoid") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:2337
Softmax activation function.
Definition activation.hpp:2422
torch::nn::functional::SoftmaxFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:2451
Softmax(const torch::nn::functional::SoftmaxFuncOptions &options)
Provides the Softmax operation.
Definition activation.hpp:2431
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="softmax") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:2468
const torch::nn::functional::SoftmaxFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:2445
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:2457
~Softmax() override=default
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:2439
Softmax(int64_t dim)
Provides the Softmax operation.
Definition activation.hpp:2426
torch::nn::functional::SoftmaxFuncOptions options_
Definition activation.hpp:2499
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="softmax") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:2484
Softmin activation function.
Definition activation.hpp:2507
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="softmin") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:2553
Softmin(int64_t dim)
Provides the Softmin operation.
Definition activation.hpp:2511
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:2524
torch::nn::functional::SoftminFuncOptions options_
Definition activation.hpp:2584
const torch::nn::functional::SoftminFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:2530
~Softmin() override=default
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:2542
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="softmin") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:2569
torch::nn::functional::SoftminFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:2536
Softmin(const torch::nn::functional::SoftminFuncOptions &options)
Provides the Softmin operation.
Definition activation.hpp:2516
Softplus activation function.
Definition activation.hpp:2592
torch::nn::functional::SoftplusFuncOptions options_
Definition activation.hpp:2676
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:2612
Softplus(torch::nn::functional::SoftplusFuncOptions options={})
Provides the Softplus operation.
Definition activation.hpp:2596
const torch::nn::functional::SoftplusFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:2618
Softplus(double beta, double threshold)
Provides the Softplus operation.
Definition activation.hpp:2602
torch::nn::functional::SoftplusFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:2624
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="softplus") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:2659
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="softplus") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:2641
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:2630
~Softplus() override=default
Softshrink activation function.
Definition activation.hpp:2689
const torch::nn::functional::SoftshrinkFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:2713
Softshrink(double lambda)
Provides the Softshrink operation.
Definition activation.hpp:2698
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="softshrink") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:2736
Softshrink(torch::nn::functional::SoftshrinkFuncOptions options={})
Provides the Softshrink operation.
Definition activation.hpp:2693
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:2707
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="softshrink") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:2752
torch::nn::functional::SoftshrinkFuncOptions options_
Definition activation.hpp:2767
torch::nn::functional::SoftshrinkFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:2719
~Softshrink() override=default
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:2725
Softsign activation function.
Definition activation.hpp:2775
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:2780
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:2786
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="softsign") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:2810
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="softsign") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:2796
Tanh activation function.
Definition activation.hpp:2827
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:2838
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="tanh") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:2848
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:2832
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="tanh") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:2862
Tanhshrink activation function.
Definition activation.hpp:2879
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:2884
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="tanhshrink") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:2914
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="tanhshrink") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:2900
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:2890
Threshold activation function.
Definition activation.hpp:2935
const torch::nn::functional::ThresholdFuncOptions & options() const
Returns constant reference to options.
Definition activation.hpp:2961
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the activation function.
Definition activation.hpp:2973
Threshold(const torch::nn::functional::ThresholdFuncOptions &options)
Provides the Threshold operation.
Definition activation.hpp:2939
~Threshold() override=default
Threshold(double threshold, double value, bool inplace=false)
Provides the Threshold operation.
Definition activation.hpp:2946
torch::nn::functional::ThresholdFuncOptions & options()
Returns non-constant reference to options.
Definition activation.hpp:2967
torch::Tensor apply(const torch::Tensor &input) const override
Applies the activation function to the given input.
Definition activation.hpp:2955
torch::serialize::InputArchive & read(torch::serialize::InputArchive &archive, const std::string &key="threshold") override
Reads the activation function from a torch::serialize::InputArchive object.
Definition activation.hpp:3004
torch::serialize::OutputArchive & write(torch::serialize::OutputArchive &archive, const std::string &key="threshold") const override
Writes the activation function into a torch::serialize::OutputArchive object.
Definition activation.hpp:2986
torch::nn::functional::ThresholdFuncOptions options_
Definition activation.hpp:3023
Full qualified name descriptor.
Definition fqn.hpp:22
virtual const std::string & name() const noexcept
Returns the full qualified name of the object.
Definition fqn.hpp:28
Full qualified name utility functions.
bool is_verbose(std::ostream &os)
Tests whether verbose output is enabled on a stream.
Definition core.hpp:871
std::ostream & operator<<(std::ostream &os, const MemoryDebugger< id > &obj)
Prints a memory debugger object.
Definition memory.hpp:145
struct iganet::@0 Log
Logger.
@ none
Definition boundary.hpp:38
activation
Enumerator for nonlinear activation functions.
Definition activation.hpp:26
short int short_t
Signed short integer type used by IgANet's compact enumerations.
Definition core.hpp:76
Definition optimizer.hpp:61