Converting a Trained Model to Torchscript Format with PyTorch
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?