Hi, All
I am trying to apply the relu to the output of each layer in C++
The python code is like:
for i in range(len(self.layers)):
m = self.layers[i]
x_f = F.relu(m(x))
where the layers are defined as
self.layers = torch.nn.ModuleList([
LinearWeightNorm(input_dim, 1000),
LinearWeightNorm(1000, 500),
LinearWeightNorm(500, 250),
LinearWeightNorm(250, 250),
LinearWeightNorm(250, 250)]
)
self.final = LinearWeightNorm(250, output_dim, weight_scale=1)
However, in C++ code, if I wrote
for (int64_t i = 0; i < 5; i++)
{
  torch::Tensor x_f = torch::nn::functional::relu(layers[i]->as<LinearWeightNorm>()->forward(x));

I met an error in “layers[i]” .
as I checked layers->size() is 0,
Any comments for better solutions please ?
Thanks.