1

当我在与我的应用程序重新启动对应的行处精确执行此代码时module.forward。下面附上代码:

@WorkerThread
@Nullable
public IValue translation(String input){       
     // loading serialized torchscript module from packaged into app android asset model.pt,
     Module module = Module.load(assetFilePath(this.context,"model_seq2seq_22_04_2020_13.pt"));

    inputTensor = generateTensor(lists,input);                 
    Log.d("tensor shape", Arrays.toString(inputTensor.shape()));


    long[] shape = new long[]{1,1};
    long[] start = new long[1];
    start[0]=0;

    Tensor trgStart = Tensor.fromBlob(start,shape);
    Log.d("tensor shape", Arrays.toString(trgStart.shape()));
    IValue output = module.forward(IValue.from(inputTensor),IValue.from(trgStart));    
}
4

0 回答 0