Can I declare activation function in class constructor?

Hi

Can I declare activation function in class(Module) constructor?

There are example using torch::nn::sequential and using torch::functional::(kinds of activation functions) in forward function directly, but I can’t find example about activation function declaration in class.

Please let me know how to declare activation function in class constructor!
(I’d like to see some example)

Thanks

You should be able to register torch::nn::ReLU() as any other module (e.g. torch::nn::Linear) in your custom class via register_module.