モデルを削除する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
delete_model メソッドを使用して、モデルを削除します。
コードサンプル
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],[],[],[],null,["# Delete a model\n\nDeletes a model using the delete_model method.\n\nCode sample\n-----------\n\n### Java\n\n\nBefore trying this sample, follow the Java setup instructions in the\n[Vertex AI quickstart using\nclient libraries](/vertex-ai/docs/start/client-libraries).\n\n\nFor more information, see the\n[Vertex AI Java API\nreference documentation](/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1).\n\n\nTo authenticate to Vertex AI, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n import com.google.api.gax.longrunning.https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.longrunning.OperationFuture.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.DeleteOperationMetadata.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ModelName.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ModelServiceClient.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ModelServiceSettings.html;\n import com.google.protobuf.https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Empty.html;\n import java.io.IOException;\n import java.util.concurrent.ExecutionException;\n import java.util.concurrent.TimeUnit;\n import java.util.concurrent.TimeoutException;\n\n public class DeleteModelSample {\n public static void main(String[] args)\n throws IOException, ExecutionException, InterruptedException, TimeoutException {\n // TODO(developer): Replace these variables before running the sample.\n String project = \"YOUR_PROJECT_ID\";\n String modelId = \"YOUR_MODEL_ID\";\n deleteModel(project, modelId);\n }\n\n static void deleteModel(String project, String modelId)\n throws IOException, ExecutionException, InterruptedException, TimeoutException {\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ModelServiceSettings.html modelServiceSettings =\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ModelServiceSettings.html.newBuilder()\n .setEndpoint(\"us-central1-aiplatform.googleapis.com:443\")\n .build();\n\n // Initialize client that will be used to send requests. This client only needs to be created\n // once, and can be reused for multiple requests. After completing all of your requests, call\n // the \"close\" method on the client to safely clean up any remaining background resources.\n try (https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ModelServiceClient.html modelServiceClient = https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ModelServiceClient.html.create(modelServiceSettings)) {\n String location = \"us-central1\";\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ModelName.html modelName = https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ModelName.html.of(project, location, modelId);\n OperationFuture\u003cEmpty, DeleteOperationMetadata\u003e operationFuture =\n modelServiceClient.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.ModelServiceClient.html#com_google_cloud_aiplatform_v1_ModelServiceClient_deleteModelAsync_com_google_cloud_aiplatform_v1_DeleteModelRequest_(modelName);\n System.out.format(\"Operation name: %s\\n\", operationFuture.getInitialFuture().get().getName());\n System.out.println(\"Waiting for operation to finish...\");\n operationFuture.get(300, TimeUnit.SECONDS);\n System.out.format(\"Deleted Model.\");\n }\n }\n }\n\n### Node.js\n\n\nBefore trying this sample, follow the Node.js setup instructions in the\n[Vertex AI quickstart using\nclient libraries](/vertex-ai/docs/start/client-libraries).\n\n\nFor more information, see the\n[Vertex AI Node.js API\nreference documentation](/nodejs/docs/reference/aiplatform/latest).\n\n\nTo authenticate to Vertex AI, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n /**\n * TODO(developer): Uncomment these variables before running the sample.\\\n */\n\n // const modelId = 'YOUR_MODEL_ID';\n // const project = 'YOUR_PROJECT_ID';\n // const location = 'YOUR_PROJECT_LOCATION';\n\n // Imports the Google Cloud Model Service Client library\n const {ModelServiceClient} = require('https://cloud.google.com/nodejs/docs/reference/aiplatform/latest/overview.html');\n\n // Specifies the location of the api endpoint\n const clientOptions = {\n apiEndpoint: 'us-central1-aiplatform.googleapis.com',\n };\n\n // Instantiates a client\n const modelServiceClient = new https://cloud.google.com/nodejs/docs/reference/aiplatform/latest/overview.html(clientOptions);\n\n async function deleteModel() {\n // Configure the resource\n const name = modelServiceClient.modelPath(project, location, modelId);\n const request = {name};\n\n // Delete Model Request\n const [response] = await modelServiceClient.deleteModel(request);\n console.log(`Long running operation: ${response.name}`);\n\n // Wait for operation to complete\n await response.promise();\n const result = response.result;\n\n console.log('Delete model response:\\n', result);\n }\n deleteModel();\n\n### Python\n\n\nBefore trying this sample, follow the Python setup instructions in the\n[Vertex AI quickstart using\nclient libraries](/vertex-ai/docs/start/client-libraries).\n\n\nFor more information, see the\n[Vertex AI Python API\nreference documentation](/python/docs/reference/aiplatform/latest).\n\n\nTo authenticate to Vertex AI, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n from google.cloud import aiplatform\n\n\n def delete_model_sample(\n project: str,\n model_id: str,\n location: str = \"us-central1\",\n api_endpoint: str = \"us-central1-aiplatform.googleapis.com\",\n timeout: int = 300,\n ):\n # The AI Platform services require regional API endpoints.\n client_options = {\"api_endpoint\": api_endpoint}\n # Initialize client that will be used to create and send requests.\n # This client only needs to be created once, and can be reused for multiple requests.\n client = aiplatform.gapic.https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform_v1.services.model_service.ModelServiceClient.html(client_options=client_options)\n name = client.https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform_v1.services.model_service.ModelServiceClient.html#google_cloud_aiplatform_v1_services_model_service_ModelServiceClient_model_path(project=project, location=location, model=model_id)\n response = client.https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform_v1.services.model_service.ModelServiceClient.html#google_cloud_aiplatform_v1_services_model_service_ModelServiceClient_delete_model(name=name)\n print(\"Long running operation:\", response.operation.name)\n delete_model_response = response.result(timeout=timeout)\n print(\"delete_model_response:\", delete_model_response)\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=aiplatform)."]]