exp remove
别名:
dvc exp rm
。
从项目中删除特定实验。
概要
usage: dvc exp remove [-h] [-q | -v] [-A] [--rev <commit>] [-n <num>]
[--queue | -g <git_remote>] [--keep]
[<name> [<name> ...]]
positional arguments:
experiment Experiments to remove.
描述
删除一个或多个实验,可通过名称指定(参见dvc exp run
)或 ID(仅限已排队的实验)。
使用--queue
时,将清空等待执行的实验列表。
选项
-
--queue
- 删除所有尚未运行的实验(通过dvc exp run --queue
定义)。 -
-A
,--all
- 删除所有已运行的实验。使用dvc queue remove
删除排队的实验任务。 -
--rev <commit>
- 以指定的<commit>
为基线,删除由此派生的所有实验。 -
-n <num>
,--num <num>
- 从--rev
基线开始,删除最近num
个提交(首个父提交)中的实验。传入负值可包含所有首个父提交(类似git log -n
)。 -
-g
,--git-remote
- 要从中删除实验的 Git 远程仓库名称或 URL。 -
--keep
- 反转-n
、--rev
等选项的默认行为。例如,-n <num> --keep
会保留最近num
个提交中的实验,删除其余所有实验。 -
-h
,--help
- 显示帮助信息并退出。 -
-q
,--quiet
- 不向标准输出写入任何内容。如果没有问题则以 0 退出,否则以 1 退出。 -
-v
,--verbose
- 显示执行dvc pull
命令时的详细跟踪信息。
示例
假设我们在项目中通过dvc exp run
运行了 3 个实验:
$ dvc exp list
master:
major-mela
conic-ease
lucid-lair
要删除其中任意一个,可将其名称传递给dvc exp remove
;或使用--all
(-A
)选项一次性删除全部:
$ dvc exp remove conic-ease lucid-lair
$ dvc exp list
master:
major-mela
$ dvc exp remove -A
$ dvc exp list
在最后一次dvc exp list
后不再显示任何内容,因为所有实验均已删除。
排队的实验同理,但这些实验尚无名称可传递给dvc exp remove
(除非你已手动指定)。你也可以使用其 ID(排队时显示,或通过dvc exp show
查看)。我们先排队几个实验,再删除其中部分:
$ dvc exp run --queue -S train.min_split=64
Queued experiment 'e41d5b4' for future execution.
$ dvc exp run --queue -S train.min_split=32 --name split32
Queued experiment '5751540' for future execution.
$ dvc exp run --queue -S train.min_split=16 --name split16
Queued experiment '8de9a6c' for future execution.
$ dvc exp remove e41d5b4 split16
$ dvc exp show
──────────────────────────────────────────────────────────────────────────────────────
Experiment Created State avg_prec roc_auc train.min_split
──────────────────────────────────────────────────────────────────────────────────────
workspace - - 0.57553 0.94652 2
master Aug 02, 2021 - 0.53252 0.9107 2
└── 5751540 [split32] 04:57 PM Queued - - 32
──────────────────────────────────────────────────────────────────────────────────────
我们还可以从远程 Git 仓库中删除实验:
$ dvc exp push myremote
$ dvc exp list myremote
master:
conic-ease
urban-sign
major-mela
$ dvc exp remove -g myremote urban-sign major-mela
$ dvc exp list myremote
master:
conic-ease
相反,若只想保留特定实验(删除其余所有),可结合--keep
标志将这些实验的名称传递给dvc exp remove
:
$ dvc exp list
master:
major-mela
conic-ease
lucid-lair
$ dvc exp remove --keep major-mela
$ dvc exp list
master:
major-mela
在此情况下,名为conic-ease
和lucid-lair
的实验被删除,仅保留major-mela
。--keep
标志同样适用于--num
(-n
)和--rev
,但不适用于--queue
。