physicalai-train-working-with-datasets
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWorking with Studio Datasets
处理Studio数据集
Studio data lives in . Datasets use the LeRobot format and are consumed through Lightning datamodules. The datamodules are first-class Python API objects; YAML/CLI configs are a serialization of the same construction path.
library/src/physicalai/data/Key modules:
- —
data/lerobot/datamodule.py(the class configs reference asLeRobotDataModule).physicalai.data.lerobot.LeRobotDataModule - — LeRobot dataset wrapper.
data/lerobot/dataset.py - —
data/lerobot/converters.py(StrEnum:DataFormat,physicalai) and bidirectional field mapping between the two layouts.lerobot - —
data/observation.py,Observation,Feature,FeatureType.NormalizationParameters - — base
data/datamodules.py(LightningDataModule, auto num-workers heuristic).LightningDataModule - — base
data/dataset.py;Dataset—data/gym.pyfor gym-generated data.GymDataset
Studio数据存储于目录下。数据集采用LeRobot格式,并通过Lightning数据模块调用。这些数据模块是一等Python API对象;YAML/CLI配置是同一构建路径的序列化形式。
library/src/physicalai/data/核心模块:
- —
data/lerobot/datamodule.py(配置文件中引用的类为LeRobotDataModule)。physicalai.data.lerobot.LeRobotDataModule - — LeRobot数据集封装器。
data/lerobot/dataset.py - —
data/lerobot/converters.py(字符串枚举类型:DataFormat、physicalai)以及两种格式间的双向字段映射。lerobot - —
data/observation.py、Observation、Feature、FeatureType。NormalizationParameters - — 基础
data/datamodules.py(基于LightningDataModule,自动计算工作进程数的启发式实现)。LightningDataModule - — 基础
data/dataset.py;Dataset— 用于gym生成数据的data/gym.py。GymDataset
Python API usage
Python API 使用方法
Use this path for notebooks, tests, direct batch inspection, or debugging dataloading without involving the training CLI.
python
from physicalai.data import LeRobotDataModule
datamodule = LeRobotDataModule(repo_id="lerobot/pusht", train_batch_size=2)
datamodule.prepare_data()
datamodule.setup("fit")
batch = next(iter(datamodule.train_dataloader()))Done when: the batch contains the observation/action fields the policy expects, with the expected batch/action dimensions.
在Notebook、测试、直接批处理检查,或不涉及训练CLI的数据加载调试场景下使用此方式。
python
from physicalai.data import LeRobotDataModule
datamodule = LeRobotDataModule(repo_id="lerobot/pusht", train_batch_size=2)
datamodule.prepare_data()
datamodule.setup("fit")
batch = next(iter(datamodule.train_dataloader()))完成标志:批处理包含策略预期的观测/动作字段,且批处理/动作维度符合预期。
Wiring data into a training config
将数据接入训练配置
In a config, the block selects the datamodule and its :
physicalai fitdatarepo_idyaml
data:
class_path: physicalai.data.lerobot.LeRobotDataModule
init_args:
repo_id: lerobot/pusht
train_batch_size: 64repo_idphysicalai-train-training-a-policy在配置中,块用于选择数据模块及其:
physicalai fitdatarepo_idyaml
data:
class_path: physicalai.data.lerobot.LeRobotDataModule
init_args:
repo_id: lerobot/pusht
train_batch_size: 64repo_idphysicalai-train-training-a-policyWorkflow
工作流程
- Pick the dataset by and confirm its features (image keys, state dim, action dim) match the target policy's
repo_id.Config- Done when: the policy's expected names and action dimension line up with the dataset.
Feature
- Done when: the policy's expected
- Verify a batch through the Python API before training:
python
datamodule.prepare_data() datamodule.setup("fit") batch = next(iter(datamodule.train_dataloader()))- Done when: the batch has correct keys and shapes without invoking the CLI.
- Verify CLI parity when the dataset is configured through YAML:
bash
physicalai fit --config <config.yaml> --trainer.fast_dev_run=true- Done when: one batch flows through with correct shapes and no missing-feature errors.
- Convert layouts only when needed via (
converters.py↔DataFormat.physicalai); keep field names stable, since they propagate to training and export.DataFormat.lerobot - Set normalization through /
NormalizationParametersconsistently with what the policy expects at inference.Feature
- 通过选择数据集,确认其特征(图像键、状态维度、动作维度)与目标策略的
repo_id匹配。Config- 完成标志:策略预期的名称和动作维度与数据集一致。
Feature
- 完成标志:策略预期的
- 训练前通过Python API验证批处理:
python
datamodule.prepare_data() datamodule.setup("fit") batch = next(iter(datamodule.train_dataloader()))- 完成标志:无需调用CLI即可获取具有正确键和形状的批处理。
- 验证YAML配置下的CLI一致性:
bash
physicalai fit --config <config.yaml> --trainer.fast_dev_run=true- 完成标志:一批数据可正常流转,形状正确且无特征缺失错误。
- 仅在必要时通过转换格式(
converters.py↔DataFormat.physicalai);保持字段名称稳定,因为它们会传播到训练和导出环节。DataFormat.lerobot - 通过/
NormalizationParameters设置归一化,确保与策略推理时的预期一致。Feature
Debugging dataloading
数据加载调试
- Missing/renamed feature → the config's dataset features disagree with the policy; align names in
Featureconventions.data/observation.py - Slow/stalled first batch → the LeRobot is downloading; expected on first run (see the
repo_idtest marker for tests that need this).requires_download - Wrong batch dimensions → check and the datamodule's collate/observation handling before changing the policy.
train_batch_size
- 特征缺失/重命名 → 配置中的数据集特征与策略不匹配;按照的约定对齐
data/observation.py名称。Feature - 首个批处理加载缓慢/停滞 → LeRobot 正在下载;首次运行时属于正常现象(需要下载的测试会标记
repo_id)。requires_download - 批处理维度错误 → 在修改策略前,检查以及数据模块的整理/观测处理逻辑。
train_batch_size
Required checks
必要检查
- Feature names, , action dim, and normalization match between dataset,
FeatureType, and any export metadata.Config - Conversions round-trip without dropping or renaming fields.
- Direct datamodule API construction and YAML config construction produce compatible batches.
- Tests that require downloads are marked ; keep default
requires_downloadrunnable offline.uv run pytest
- 数据集、以及任何导出元数据之间的特征名称、
Config、动作维度和归一化设置保持一致。FeatureType - 格式转换可往返进行,不会丢失或重命名字段。
- 直接通过数据模块API构建和通过YAML配置构建可生成兼容的批处理。
- 需要下载的测试标记;确保默认的
requires_download可离线运行。uv run pytest
Verify
验证
bash
undefinedbash
undefinedfrom library/
进入library/目录
uv run pytest tests/unit/data tests/unit/datamodules
undefineduv run pytest tests/unit/data tests/unit/datamodules
undefinedRelated skills
相关技能
- — the
physicalai-train-training-a-policyblock is one half of a training config.data - — align observation features with the policy
physicalai-train-adding-a-policy.Config
- —
physicalai-train-training-a-policy块是训练配置的组成部分之一。data - — 将观测特征与策略
physicalai-train-adding-a-policy对齐。Config