GFN icon indicating copy to clipboard operation
GFN copied to clipboard

Converting a Trained Model to Torchscript Format with PyTorch

Open china20000420 opened this issue 1 year ago • 0 comments

I'm glad that the code is running successfully! However, I encountered an error while converting my trained model to Torchscript: RuntimeError: getattr's second argument must be a string literal: File "/root/miniconda3/lib/python3.8/site-packages/pytorch_metric_learning/utils/common_functions.py", line 275 def reset_stats(input_obj): for attr_list in ["_record_these_stats"]: for r in getattr(input_obj, attr_list, []): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE It seems there is an issue with the following code:

`# def reset_stats(input_obj):

for attr_list in ["_record_these_stats"]:

for r in getattr(input_obj, attr_list, []):

setattr(input_obj, r, 0)

` I have been trying to resolve this for over two weeks and am not sure how to accurately and correctly convert the model to Torchscript format. Do you have any suggestions?

china20000420 avatar May 29 '24 14:05 china20000420