I’m learning how to port a module onto an Android app, but I’ve found that the output is a bit different on Android compared to the Python script.
Here’s my model:
class Dummy(nn.Module):
def __init__(self):
super(Dummy, self).__init__()
self.fc = nn.Linear(416 * 416 * 3, 10)
def forward(self, x):
x = x.reshape(x.shape[0], -1)
x = self.fc(x)
return x
And the model convert script:
model = Dummy()
model.load_state_dict(torch.load("dummy.pt"))
example = torch.randn(1, 3, 416, 416)
traced_script_module = torch.jit.trace(model, example)
traced_script_module.save("dummy-android.pt")
In the Python script, the output to my example image was:
[-0.1566336453, 0.0841832012, 0.0985929519, 0.0115705878, -0.3650150299, 0.3889884949, 0.0307857171, -0.1416997164, 0.2296864390, -0.2360394597]
And on Android:
[-0.15890475, 0.07862158, 0.09994077, 0.015047294, -0.3655298, 0.38745546, 0.03088907, -0.13880219, 0.23389207, -0.24074274]
Is this behavior normal?
Thanks in advance!