(run)
| 52 | run.log_artifact(raw_data) |
| 53 | |
| 54 | def test_download_artifact(run): |
| 55 | |
| 56 | # 对数据进行预处理后,再进行保存 |
| 57 | steps = {"normalize": True, |
| 58 | "expand_dims": True} |
| 59 | processed_data = wandb.Artifact( |
| 60 | "mnist-preprocess", type="dataset", |
| 61 | description="Preprocessed MNIST dataset", |
| 62 | metadata=steps) |
| 63 | |
| 64 | # ✔️ declare which artifact we'll be using |
| 65 | raw_data_artifact = run.use_artifact('mnist-origin:latest') |
| 66 | |
| 67 | # 📥 if need be, download the artifact |
| 68 | raw_dataset = raw_data_artifact.download() |
| 69 | |
| 70 | for split in ["training"]: |
| 71 | raw_split = read(raw_dataset, split) |
| 72 | processed_dataset = preprocess(raw_split, **steps) |
| 73 | |
| 74 | with processed_data.new_file(split + ".pt", mode="wb") as file: |
| 75 | x, y = processed_dataset.tensors |
| 76 | torch.save((x, y), file) |
| 77 | |
| 78 | run.log_artifact(processed_data) |
| 79 | |
| 80 | def count_down(duration:int): |
| 81 | for remaining in range(duration, 0, -1): |
no test coverage detected