AWS Doc SDK ExamplesWord
기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
an AWS SDKCreateModel
와 함께 사용
다음 코드 예시에서는 CreateModel
을 사용하는 방법을 보여 줍니다.
자세한 내용은 모델 훈련을 참조하십시오.
- Python
-
- Python용 SDK(Boto3)
-
참고
더 많은 on GitHub가 있습니다. AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. class Models: @staticmethod def create_model( lookoutvision_client, project_name, training_results, tag_key=None, tag_key_value=None, ): """ Creates a version of a Lookout for Vision model. :param lookoutvision_client: A Boto3 Lookout for Vision client. :param project_name: The name of the project in which you want to create a model. :param training_results: The Amazon S3 location where training results are stored. :param tag_key: The key for a tag to add to the model. :param tag_key_value - A value associated with the tag_key. return: The model status and version. """ try: logger.info("Training model...") output_bucket, output_folder = training_results.replace("s3://", "").split( "/", 1 ) output_config = { "S3Location": {"Bucket": output_bucket, "Prefix": output_folder} } tags = [] if tag_key is not None: tags = [{"Key": tag_key, "Value": tag_key_value}] response = lookoutvision_client.create_model( ProjectName=project_name, OutputConfig=output_config, Tags=tags ) logger.info("ARN: %s", response["ModelMetadata"]["ModelArn"]) logger.info("Version: %s", response["ModelMetadata"]["ModelVersion"]) logger.info("Started training...") print("Training started. Training might take several hours to complete.") # Wait until training completes. finished = False status = "UNKNOWN" while finished is False: model_description = lookoutvision_client.describe_model( ProjectName=project_name, ModelVersion=response["ModelMetadata"]["ModelVersion"], ) status = model_description["ModelDescription"]["Status"] if status == "TRAINING": logger.info("Model training in progress...") time.sleep(600) continue if status == "TRAINED": logger.info("Model was successfully trained.") else: logger.info( "Model training failed: %s ", model_description["ModelDescription"]["StatusMessage"], ) finished = True except ClientError: logger.exception("Couldn't train model.") raise else: return status, response["ModelMetadata"]["ModelVersion"]
-
API 세부 정보는 Word for Python(Boto3) CreateModel 참조의 Word를 참조하세요. AWS SDK API
-
CreateDataset
CreateProject