跳转至

Weights & Biases

236 个字 58 行代码 预计阅读时间 2 分钟

Abstract

wandb 常用命令

wandb.init

wandb.init

初始化一个新的运行,返回一个 wandb.Run 对象。

run = wandb.init(
   project="project_name",
   entity="entity_name",
   name="run_name",
   config=config, # 超参数
   ...
)

...

run.finish()

wandb.log

wandb.log

使用 log 记录运行中的数据,例如标量、图像、视频、直方图、绘图和表格。

wandb.log(
   data: Dict[str, Any],
   step: Optional[int] = None,
   commit: Optional[bool] = None,
   sync: Optional[bool] = None
) -> None
run.log({
   "train/accuracy": 0.9,
   "train/loss": 30,
   "validate/accuracy": 0.8,
   "validate/loss": 20,
})

wandb.Image

wandb.Image

格式化图像以记录到 W&B

Image(
   data_or_path: "ImageDataOrPathType",
   mode: Optional[str] = None,
   caption: Optional[str] = None,
   grouping: Optional[int] = None,
   classes: Optional[Union['Classes', Sequence[dict]]] = None,
   boxes: Optional[Union[Dict[str, 'BoundingBoxes2D'], Dict[str, dict]]] = None,
   masks: Optional[Union[Dict[str, 'ImageMask'], Dict[str, dict]]] = None,
   file_type: Optional[str] = None
) -> None
examples = []
for i in range(3):
   pixels = np.random.randint(low=0, high=256, size=(100, 100, 3))
   image = wandb.Image(pixels, caption=f"random field {i}")
   examples.append(image)
run.log({"examples": examples})

wandb.Table

wandb.Table

Table 类,用于显示和分析表格数据。

Table(
   columns=None,
   data=None,
   rows=None,
   dataframe=None,
   dtype=None,
   optional=(True),
   allow_mixed_types=(False)
)
my_table = wandb.Table(columns=["a", "b"], data=[["a1", "b1"], ["a2", "b2"]])
run.log({"Table Name": my_table})

Artifact

Artifact

用于数据集和模型版本控制的构件。

Artifact(
   name: str,
   type: str,
   description: Optional[str] = None,
   metadata: Optional[Dict[str, Any]] = None,
   incremental: bool = (False),
   use_as: Optional[str] = None
) -> None

Data Types

Data Types Description
Audio Wandb class for audio clips.
BoundingBoxes2D Format images with 2D bounding box overlays for logging to W&B.
Graph Wandb class for graphs.
Histogram wandb class for histograms.
Html Wandb class for arbitrary html.
Image Format images for logging to W&B.
ImageMask Format image masks or overlays for logging to W&B.
Molecule Wandb class for 3D Molecular data.
Object3D Wandb class for 3D point clouds.
Plotly Wandb class for plotly plots.
Table The Table class used to display and analyze tabular data.
Video Format a video for logging to W&B.
WBTraceTree Media object for trace tree data.

Reference


最后更新: 2024年10月15日 21:50:29
创建日期: 2024年10月15日 21:50:29
回到页面顶部