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)
When I change to
auto a=layers[0+i]->as()->forward(x);
The error reports “index out of range”
terminate called after throwing an instance of ‘c10::Error’
I defined the layers as
struct DiscriminatorImpl:torch::nn::Module {
torch::Tensor x;