謝謝你在社區磚貼出你的問題。
下麵的步驟節省Keras模型從一個Python筆記本在AWS S3 bucket磚:
#設置憑證和S3創建客戶端導入boto3導入操作係統aws_access_key_id = dbutils.secrets。get(範圍= " < scope-name >”,關鍵=“<鍵名>”)aws_secret_access_key = dbutils.secrets。get(範圍= " < scope-name >”,關鍵=“<鍵名>”)操作係統。環境[' AWS_ACCESS_KEY_ID '] = AWS_ACCESS_KEY_ID操作係統。環境[' AWS_SECRET_ACCESS_KEY '] = AWS_SECRET_ACCESS_KEY s3_client = boto3.client (s3) #上傳保存的模型從本地文件係統s3 bucket s3_bucket =“< bucket名>”s3_prefix = model_path =“< bucket-prefix > / dbfs /模型/模型。h5 " s3_key = " {} / model.h5”.format s3_client (s3_prefix)。upload_file (model_path s3_bucket s3_key)
請檢查下麵的代碼如何加載保存模型從s3 bucket嗎
從keras進口boto3導入操作係統。模型導入load_model #憑證和創建客戶機aws_access_key_id = dbutils.secrets S3。get(範圍= " < scope-name >”,關鍵=“<鍵名>”)aws_secret_access_key = dbutils.secrets。get(範圍= " < scope-name >”,關鍵=“<鍵名>”)操作係統。環境[' AWS_ACCESS_KEY_ID '] = AWS_ACCESS_KEY_ID操作係統。環境[' AWS_SECRET_ACCESS_KEY '] = AWS_SECRET_ACCESS_KEY s3_client = boto3.client (s3) #指定s3 bucket和模型文件路徑s3_bucket =“< bucket名>”s3_prefix = " < bucket-prefix > " s3_key = " {} / model.h5 " .format (s3_prefix) #下載模型文件從s3 local_model_path = " / dbfs /模型/模型。s3_client h5”。download_file (s3_bucket s3_key local_model_path) #加載模型使用Keras loaded_model = load_model (local_model_path)
謝謝你在社區磚貼出你的問題。
下麵的步驟節省Keras模型從一個Python筆記本在AWS S3 bucket磚:
#設置憑證和S3創建客戶端導入boto3導入操作係統aws_access_key_id = dbutils.secrets。get(範圍= " < scope-name >”,關鍵=“<鍵名>”)aws_secret_access_key = dbutils.secrets。get(範圍= " < scope-name >”,關鍵=“<鍵名>”)操作係統。環境[' AWS_ACCESS_KEY_ID '] = AWS_ACCESS_KEY_ID操作係統。環境[' AWS_SECRET_ACCESS_KEY '] = AWS_SECRET_ACCESS_KEY s3_client = boto3.client (s3) #上傳保存的模型從本地文件係統s3 bucket s3_bucket =“< bucket名>”s3_prefix = model_path =“< bucket-prefix > / dbfs /模型/模型。h5 " s3_key = " {} / model.h5”.format s3_client (s3_prefix)。upload_file (model_path s3_bucket s3_key)