실험 만들기
"""
Create an experiment in W&B. If the project does not exist, W&B creates it.
Note that this file only initializes the experiment; you can add code to log metrics,
artifacts, etc., within the `with` block.
"""
import wandb
# W&B run을 초기화합니다
with wandb.init(project="<project>") as run:
# 여기에 실험 코드를 작성하세요
pass
특정 step에서 기존 run 포크하기
"""Fork an existing W&B run from a specific step."""
import wandb
# 나중에 분기할 run을 초기화합니다
with wandb.init(project="<project>", entity="<entity>") as original_run:
# 여기에 트레이닝 및 로깅 코드를 작성합니다.
pass
# 특정 step에서 run을 분기합니다. 이 예제에서는 step 200에서 분기합니다. 필요에 따라 step 숫자를 조정할 수 있습니다.
with wandb.init(project="<project>",entity="<entity>", fork_from=f"{original_run.id}?_step=200") as forked_run:
# 여기에 트레이닝 및 로깅 코드를 작성합니다.
pass
run 초기화
"""
Initializes a W&B run.
W&B automatically creates the project if it does not exist. Note that this
file only initializes the experiment; you can add code to log metrics,
artifacts, etc., within the `with` block.
"""
import wandb
# 리소스를 올바르게 관리하기 위해 `with` 문을 사용한다는 점에 유의하세요.
with wandb.init(project="<project>") as run:
# 여기에 트레이닝 및 로깅 코드를 작성하세요
pass
run이 일시 중지, 중단 또는 실패한 경우의 재개 동작 설정
"""
Set resume behaviour for a run if it is paused, stops, or fails.
This is useful for long-running experiments that may be interrupted. See
reference documentation for wandb.init(resume=) for a list of all resume options.
"""
import wandb
# W&B run을 재개 동작으로 초기화합니다
with wandb.init(project="<project>", resume="<resume_option>") as run:
# 트레이닝 및 로깅 코드는 여기에 작성하세요
pass
run을 되감아 run의 이력 수정하기
"""
Rewind a run to modify the history of a run.
Specify the run ID and step to rewind to with the `resume_from` parameter in `wandb.init()`.
"""
import wandb
import math
# run을 초기화하고 메트릭을 로깅합니다
with wandb.init(project="<project>", entity="<entity>") as run:
# 여기에 트레이닝 및 로깅 코드를 작성합니다
pass
run_ID = "<run_id>" # 원본 run의 run ID로 바꾸세요
step = int("<step>") # 되감을 step을 지정하세요
# 원본 run의 지정된 step부터 재개하는 새 run을 시작합니다
with wandb.init(project="<project>", entity="<entity>", resume_from=f"{run_ID}?_step={step}") as run:
# 여기에 트레이닝 및 로깅 코드를 작성합니다
pass
run에 하나 이상의 태그 추가
"""
Add one or more tags to a run.
"""
import wandb
with wandb.init(entity="<entity>", project="<project>", tags=["<tag1>", "<tag2>"]) as run:
# 여기에 트레이닝 및 로깅 코드를 작성하세요
pass
group에 run 하나 이상 추가
"""
Add one or more runs to a group.
Pass the name of your group as an argument to the `group` parameter when you
initialize a run with `wandb.init(group="")`.
"""
import wandb
entity = "<entity>"
project = "<project>"
# 다음은 각 group에 3개의 run이 있는 3개의 group을 생성합니다.
for group in ["<GroupA>", "<GroupB>", "<GroupC>"]: # 원하는 group 이름으로 교체하세요
# 각 group에 대해 세 개의 run을 생성하는 것을 시뮬레이션합니다.
for i in range(3):
with wandb.init(entity=entity, project=project, group=group, name=f"{group}_run_{i}") as run:
# 트레이닝 및 로깅 코드가 여기에 옵니다
pass
작업 유형별로 run 정리하기
"""
Organize runs by their job type.
Add a job type to a run by passing the `job_type` parameter to `wandb.init(job_type="")`.
"""
import wandb
entity = "<entity>"
project = "<project>"
# run을 생성하고 작업 유형별로 정리합니다.
for job_type in ["<JobType1>", "<JobType2>"]: # 실제 작업 유형 이름으로 바꾸세요
# 작업 유형별로 run을 두 개씩 생성하는 과정을 시뮬레이션합니다.
for i in range(2):
with wandb.init(entity=entity, project=project, job_type=job_type, name=f"{job_type}_run_{i}") as run:
# 여기에 트레이닝 및 로깅 코드를 작성하세요
pass
활성 run에 태그를 하나 이상 추가하기
"""
Add one or more tags to an active run.
A run object's `tags` property is a tuple. To add a new tag to an existing run,
update the `tags` property with a new tuple that includes the existing tags and the new tag(s).
"""
import wandb
with wandb.init(entity="<entity>", project="<project>", tags=["<tag1>", "<tag2>"]) as run:
# 여기에 트레이닝 및 로깅 코드를 작성합니다
# 기존 태그와 새 태그를 모두 담은 새 튜플을 만들어 기존 태그에 새 태그를 추가합니다.
run.tags += ("<tag3>",)
이전에 저장한 run에 하나 이상의 태그 추가
"""
이전에 저장된 실행에 하나 이상의 태그를 추가합니다.
Public API를 사용하여 실행이 완료된 후 또는
실행 프로세스 외부에서 작업할 때 저장된 데이터의 태그를 업데이트하세요. 이는 실행을 소급하여
조직하거나 분류해야 할 때 유용합니다.
실행에 새 태그를 추가하려면 기존 태그와 새 태그를 포함하는 새 목록으로 `tags` 속성을 업데이트하세요. 실행의 경로는
`entity/project/run_id`로 구성됩니다. 태그를 업데이트한 후에는 실행의
`update()` 메서드를 호출하여 변경 사항을 저장해야 합니다.
"""
import wandb
entity = "<entity>"
project = "<project>"
run_id = "<run-id>" # 업데이트할 run의 ID로 바꾸세요
# 경로 형식: entity/project/run_id
with wandb.Api().run(f"{entity}/{project}/{run_id}") as run:
run.tags.append("<tag>")
run.update()