Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Neural network(model.pt) internal parameter type error #57

Open
gooooooa opened this issue Jan 21, 2020 · 0 comments
Open

Neural network(model.pt) internal parameter type error #57

gooooooa opened this issue Jan 21, 2020 · 0 comments

Comments

@gooooooa
Copy link

gooooooa commented Jan 21, 2020

I am trying to replace the neural network model
with my own model. My own model works well in Pytorch. And I have converted my own model to TorchScript.

The following is specific error :

`E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.abc.APP, PID: 27480
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { act=inline-data (has extras) }} to activity {com.abc.APP/com.abc.APP.MainActivity}: java.lang.RuntimeException: Expected object of scalar type Int but got scalar type Float for argument #2 'mat2' in call to _th_mm
The above operation failed in interpreter.
Traceback (most recent call last):
File "C:\Users\aaa\AppData\Local\conda\conda\envs\pytorch\lib\site-packages\torch\nn\functional.py", line 1372
ret = torch.addmm(bias, input, weight.t())
else:
output = input.matmul(weight.t())
~~~~~~~~~~~~ <--- HERE
if bias is not None:
output += bias
Serialized File "code/torch/torch/nn/functional/___torch_mangle_948.py", line 13
ret = torch.addmm(bias0, input, torch.t(weight), beta=1, alpha=1)
else:
output = torch.matmul(input, torch.t(weight))
~~~~~~~~~~~~ <--- HERE
if torch.isnot(bias, None):
bias1 = unchecked_cast(Tensor, bias)

    at android.app.ActivityThread.deliverResults(ActivityThread.java:4423)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:4465)
    at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:201)
    at android.app.ActivityThread.main(ActivityThread.java:6810)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
 Caused by: java.lang.RuntimeException: Expected object of scalar type Int but got scalar type Float for argument #2 'mat2' in call to _th_mm
The above operation failed in interpreter.
Traceback (most recent call last):
  File "C:\Users\aaa\AppData\Local\conda\conda\envs\pytorch\lib\site-packages\torch\nn\functional.py", line 1372
        ret = torch.addmm(bias, input, weight.t())
    else:
        output = input.matmul(weight.t())
                 ~~~~~~~~~~~~ <--- HERE
        if bias is not None:
            output += bias
Serialized   File "code/__torch__/torch/nn/functional/___torch_mangle_948.py", line 13
    ret = torch.addmm(bias0, input, torch.t(weight), beta=1, alpha=1)
  else:
    output = torch.matmul(input, torch.t(weight))
             ~~~~~~~~~~~~ <--- HERE
    if torch.__isnot__(bias, None):
      bias1 = unchecked_cast(Tensor, bias)

    at org.pytorch.NativePeer.forward(Native Method)
    at org.pytorch.Module.forward(Module.java:37)
    at com.abc.APP.Classifier.predict(Classifier.java:60)
    at com.abc.APP.MainActivity.onActivityResult(MainActivity.java:59)
    at android.app.Activity.dispatchActivityResult(Activity.java:7590)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:4416)
    	... 11 more`

could you help me ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant