标题说明了一切 - 我想在 s3 存储桶中保存一个 pytorch 模型。我尝试的是以下内容:
import boto3
s3 = boto3.client('s3')
saved_model = model.to_json()
output_model_file = output_folder + "pytorch_model.json"
s3.put_object(Bucket="power-plant-embeddings", Key=output_model_file, Body=saved_model)
不幸的是,这不起作用,因为.to_json()
仅适用于 tensorflow 模型。有谁知道如何在pytorch中做到这一点?
尝试将模型序列化到缓冲区并将其写入 S3:
buffer = io.BytesIO()
torch.save(model, buffer)
s3.put_object(Bucket="power-plant-embeddings", Key=output_model_file, Body=buffer.getvalue())
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句