Hi, There was a problem while I was converting the code. (python to c++)
C++ BatchNorm results differed in Python results.
# Python
class My_model(nn.Module):
def init(self):
super(My_model), self).__init__()
self.conv1 = torch.nn.Conv1d(15, 64, 1)
self.bn1 = nn.BatchNorm1d(64)
def forward(self, x):
x = self.conv1(x) # result is same in python and C++
x = self.bn1(x) # result is different in python and C++
print(x)
//C++
class My_model : public torch::nn::Module{
public:
torch::Tensor forward(torch::Tensor x);
private:
torch::nn::Conv1d conv1 = torch::nn::Conv1d(torch::nn::Conv1dOptions(15, 64, 1)); // result is same in python and C++
torch::nn::BatchNorm1d bn1= torch::nn::BatchNorm1d(torch::nn::BatchNorm1dOptions(64)); // result is different in python and C++
}
My_model model = My_model();
model.forward(x);
I checked same Input x.
Python model weight and model bias reflected in the weight and bias of the C++ model.
Is there a solution or something mistake?