Skip to content

Commit

Permalink
Basic tutorial (#303)
Browse files Browse the repository at this point in the history
Adds a simple tutorial start-to-finish tutorial for DaCapo.
Still a few things left to resolve before its ready for merging:

- [ ] Loss behaving strangely after the first validation (temporary
solution involves giving an extra singleton dimension to the provided
data)
- [ ] Validation fails (we want to show validation loss/scores,
validation outputs across iterations, and how to finally take the best
iteration and apply it with the post processing to a volume manually)
- [ ] stdout too verbose
- [ ] plotting functions should be built into `DaCapo` (there are
plotting functions, not sure how to include bokeh plots so I didn't dive
too deep into this)
  • Loading branch information
mzouink authored Oct 16, 2024
2 parents 1369fa3 + 0ef4f61 commit 8de17a3
Show file tree
Hide file tree
Showing 4 changed files with 401 additions and 8 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ jobs:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- name: install dacapo
# run: pip install .[docs]
run: pip install sphinx-autodoc-typehints sphinx-autoapi sphinx-click sphinx-rtd-theme myst-parser
run: pip install sphinx-autodoc-typehints sphinx-autoapi sphinx-click sphinx-rtd-theme myst-parser jupytext ipykernel nbsphinx
- name: parse notebooks
run: jupytext --to notebook --execute ./docs/source/notebooks/*.py
- name: remove notebook scripts
run: rm ./docs/source/notebooks/*.py
- name: Build and Commit
uses: sphinx-notes/pages@v2
with:
Expand Down
19 changes: 12 additions & 7 deletions dacapo/experiments/tasks/losses/affinities_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@ def compute(self, prediction, target, weight):
weight[:, self.num_affinities :, ...],
)

return (
torch.nn.BCEWithLogitsLoss(reduction="none")(affs, affs_target)
* affs_weight
).mean() + self.lsds_to_affs_weight_ratio * (
torch.nn.MSELoss(reduction="none")(torch.nn.Sigmoid()(aux), aux_target)
* aux_weight
).mean()
if aux.shape[1] == 0:
return torch.nn.BCEWithLogitsLoss(reduction="none")(
affs, affs_target
).mean()
else:
return (
torch.nn.BCEWithLogitsLoss(reduction="none")(affs, affs_target)
* affs_weight
).mean() + self.lsds_to_affs_weight_ratio * (
torch.nn.MSELoss(reduction="none")(torch.nn.Sigmoid()(aux), aux_target)
* aux_weight
).mean()
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

overview
install
notebooks/minimal_tutorial
tutorial
docker
aws
Expand Down
Loading

0 comments on commit 8de17a3

Please sign in to comment.