Skip to content

Commit

Permalink
add paths for yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
davidackerman committed Feb 14, 2024
1 parent 9574af5 commit fed8a6d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 37 deletions.
37 changes: 14 additions & 23 deletions examples/distance_task/liver_peroxisome.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,19 @@
"metadata": {},
"source": [
"## Config Store\n",
"To define where the data goes, create a dacapo.yaml configuration file either in `~/.config/dacapo/dacapo.yaml` or in `./dacapo.yaml`. Here is a template:\n",
"\n",
"To define where the data goes, create a dacapo.yaml configuration file. Here is a template:\n",
"```yaml \n",
"```yaml\n",
"mongodbhost: mongodb://dbuser:dbpass@dburl:dbport/\n",
"mongodbname: dacapo\n",
"runs_base_dir: /path/to/my/data/storage\n",
"```\n",
"The runs_base_dir defines where your on-disk data will be stored. The mongodbhost and mongodbname define the mongodb host and database that will store your cloud data. If you want to store everything on disk, replace mongodbhost and mongodbname with a single type `files` and everything will be saved to disk:\n",
"\n",
"The `runs_base_dir` defines where your on-disk data will be stored. The `mongodbhost` and `mongodbname` define the mongodb host and database that will store your cloud data. If you want to store everything on disk, replace `mongodbhost` and `mongodbname` with a single type: files and everything will be saved to disk:\n",
"\n",
"```yaml \n",
"```yaml\n",
"type: files\n",
"runs_base_dir: /path/to/my/data/storage\n",
"```"
"```\n"
]
},
{
Expand Down Expand Up @@ -489,24 +488,9 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
"ename": "RuntimeError",
"evalue": "Error(s) in loading state_dict for Model:\n\tsize mismatch for prediction_head.weight: copying a param with shape torch.Size([14, 72, 1, 1, 1]) from checkpoint, the shape in current model is torch.Size([1, 72, 1, 1, 1]).\n\tsize mismatch for prediction_head.bias: copying a param with shape torch.Size([14]) from checkpoint, the shape in current model is torch.Size([1]).\n\tsize mismatch for chain.1.weight: copying a param with shape torch.Size([14, 72, 1, 1, 1]) from checkpoint, the shape in current model is torch.Size([1, 72, 1, 1, 1]).\n\tsize mismatch for chain.1.bias: copying a param with shape torch.Size([14]) from checkpoint, the shape in current model is torch.Size([1]).",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[7], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mdacapo\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtrain\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m train_run\n\u001b[0;32m----> 3\u001b[0m run \u001b[38;5;241m=\u001b[39m \u001b[43mRun\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconfig_store\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mretrieve_run_config\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrun_config\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mname\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 4\u001b[0m train_run(run)\n",
"File \u001b[0;32m/groups/cellmap/cellmap/ackermand/Programming/dacapo/dacapo/experiments/run.py:63\u001b[0m, in \u001b[0;36mRun.__init__\u001b[0;34m(self, run_config)\u001b[0m\n\u001b[1;32m 57\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstart \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 58\u001b[0m Start(run_config\u001b[38;5;241m.\u001b[39mstart_config)\n\u001b[1;32m 59\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m run_config\u001b[38;5;241m.\u001b[39mstart_config \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 60\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 61\u001b[0m )\n\u001b[1;32m 62\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstart \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m---> 63\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstart\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minitialize_weights\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmodel\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m/groups/cellmap/cellmap/ackermand/Programming/dacapo/dacapo/experiments/starts/start.py:19\u001b[0m, in \u001b[0;36mStart.initialize_weights\u001b[0;34m(self, model)\u001b[0m\n\u001b[1;32m 17\u001b[0m logger\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mloading weights from run \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mrun\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m, criterion: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcriterion\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 18\u001b[0m \u001b[38;5;66;03m# load the model weights (taken from torch load_state_dict source)\u001b[39;00m\n\u001b[0;32m---> 19\u001b[0m \u001b[43mmodel\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mload_state_dict\u001b[49m\u001b[43m(\u001b[49m\u001b[43mweights\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstrict\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m/groups/scicompsoft/home/ackermand/miniconda3/envs/dacapo/lib/python3.10/site-packages/torch/nn/modules/module.py:2153\u001b[0m, in \u001b[0;36mModule.load_state_dict\u001b[0;34m(self, state_dict, strict, assign)\u001b[0m\n\u001b[1;32m 2148\u001b[0m error_msgs\u001b[38;5;241m.\u001b[39minsert(\n\u001b[1;32m 2149\u001b[0m \u001b[38;5;241m0\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mMissing key(s) in state_dict: \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m. \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mformat(\n\u001b[1;32m 2150\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m, \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mk\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m k \u001b[38;5;129;01min\u001b[39;00m missing_keys)))\n\u001b[1;32m 2152\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(error_msgs) \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[0;32m-> 2153\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mRuntimeError\u001b[39;00m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mError(s) in loading state_dict for \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m:\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\t\u001b[39;00m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mformat(\n\u001b[1;32m 2154\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__class__\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\t\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(error_msgs)))\n\u001b[1;32m 2155\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m _IncompatibleKeys(missing_keys, unexpected_keys)\n",
"\u001b[0;31mRuntimeError\u001b[0m: Error(s) in loading state_dict for Model:\n\tsize mismatch for prediction_head.weight: copying a param with shape torch.Size([14, 72, 1, 1, 1]) from checkpoint, the shape in current model is torch.Size([1, 72, 1, 1, 1]).\n\tsize mismatch for prediction_head.bias: copying a param with shape torch.Size([14]) from checkpoint, the shape in current model is torch.Size([1]).\n\tsize mismatch for chain.1.weight: copying a param with shape torch.Size([14, 72, 1, 1, 1]) from checkpoint, the shape in current model is torch.Size([1, 72, 1, 1, 1]).\n\tsize mismatch for chain.1.bias: copying a param with shape torch.Size([14]) from checkpoint, the shape in current model is torch.Size([1])."
]
}
],
"outputs": [],
"source": [
"from dacapo.train import train_run\n",
"\n",
Expand All @@ -520,6 +504,13 @@
"source": [
"If you want to start your run on some compute cluster, you might want to use the command line interface: dacapo train -r {run_config.name}. This makes it particularly convenient to run on compute nodes where you can specify specific compute requirements."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
34 changes: 20 additions & 14 deletions examples/distance_task/liver_peroxisome.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ DaCapo has 4 major configurable components:
These are then combined in a single **dacapo.experiments.Run** that includes your starting point (whether you want to start training from scratch or continue off of a previously trained model) and stopping criterion (the number of iterations you want to train).

## Environment setup
If you have not already done so, you will need to install DaCapo. We recommend you do this by first creating a new environment and then installing DaCapo using pip.
If you have not already done so, you will need to install DaCapo. You can do this by first creating a new environment and then installing DaCapo using pip.

```bash
conda create -n dacapo python=3.10
Expand All @@ -35,24 +35,25 @@ cd dacapo
pip install -e .
```

Be sure to select this environment in your Jupyter notebook or JupyterLab.

## Config Store
To define where the data goes, create a dacapo.yaml configuration file either in `~/.config/dacapo/dacapo.yaml` or in `./dacapo.yaml`. Here is a template:

To define where the data goes, create a dacapo.yaml configuration file. Here is a template:
```yaml
```yaml
mongodbhost: mongodb://dbuser:dbpass@dburl:dbport/
mongodbname: dacapo
runs_base_dir: /path/to/my/data/storage
```
The runs_base_dir defines where your on-disk data will be stored. The mongodbhost and mongodbname define the mongodb host and database that will store your cloud data. If you want to store everything on disk, replace mongodbhost and mongodbname with a single type `files` and everything will be saved to disk:

The `runs_base_dir` defines where your on-disk data will be stored. The `mongodbhost` and `mongodbname` define the mongodb host and database that will store your cloud data. If you want to store everything on disk, replace `mongodbhost` and `mongodbname` with a single type: files and everything will be saved to disk:

```yaml
```yaml
type: files
runs_base_dir: /path/to/my/data/storage
```



```python
from dacapo.store.create_store import create_config_store
Expand Down Expand Up @@ -357,13 +358,13 @@ from dacapo.experiments.run import Run
start_config = None
# Uncomment to start from a pretrained model
# start_config = StartConfig(
# "setup04",
# "best",
# )
start_config = StartConfig(
"setup04",
"best",
)
iterations = 200000
validation_interval = 5000
validation_interval = 5
repetitions = 3
for i in range(repetitions):
run_config = RunConfig(
Expand Down Expand Up @@ -392,9 +393,9 @@ for i in range(repetitions):
config_store.store_run_config(run_config)
```

example_scratch_example_jrc_mus-livers_peroxisome_8nm_example_distances_8nm_peroxisome_example_attention-upsample-unet_example_default_one_label_finetuning__0
example_scratch_example_jrc_mus-livers_peroxisome_8nm_example_distances_8nm_peroxisome_example_attention-upsample-unet_example_default_one_label_finetuning__1
example_scratch_example_jrc_mus-livers_peroxisome_8nm_example_distances_8nm_peroxisome_example_attention-upsample-unet_example_default_one_label_finetuning__2
example_finetuned_example_jrc_mus-livers_peroxisome_8nm_example_distances_8nm_peroxisome_example_attention-upsample-unet_example_default_one_label_finetuning__0
example_finetuned_example_jrc_mus-livers_peroxisome_8nm_example_distances_8nm_peroxisome_example_attention-upsample-unet_example_default_one_label_finetuning__1
example_finetuned_example_jrc_mus-livers_peroxisome_8nm_example_distances_8nm_peroxisome_example_attention-upsample-unet_example_default_one_label_finetuning__2


## Train
Expand All @@ -410,3 +411,8 @@ train_run(run)
```

If you want to start your run on some compute cluster, you might want to use the command line interface: dacapo train -r {run_config.name}. This makes it particularly convenient to run on compute nodes where you can specify specific compute requirements.


```python
```

0 comments on commit fed8a6d

Please sign in to comment.