added backward sampling in a layer-wise manner - #412
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #412 +/- ##
==========================================
- Coverage 68.71% 67.86% -0.86%
==========================================
Files 58 58
Lines 6007 6114 +107
Branches 773 790 +17
==========================================
+ Hits 4128 4149 +21
- Misses 1590 1675 +85
- Partials 289 290 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| torch.zeros(num_samples, dtype=torch.long, device=device), | ||
| ) | ||
|
|
||
| samples = torch.zeros(num_samples, circuit.num_variables, dtype=torch.long, device=device) |
There was a problem hiding this comment.
If we want to allow for heterogeneous inputs (as is the case in TabPC, where we have both categoricals and Gaussians), setting the dtype explicitly as int here causes errors later when we try to write floats into the samples tensor. Equally, if it is set to be float then we will have to cast the integer samples from the TorchCategoricalLayer before writing them.
There was a problem hiding this comment.
On this note, would be nice if you or I could push the code for gaussian layers
| # Sample which of (Ki * arity) inputs each path follows, then split by arity slot. | ||
| sample_ids, folds, units = selection | ||
| weight = self.weight() | ||
| # Shared-parameter layers replicate `weight` across folds — collapse fold index. |
There was a problem hiding this comment.
nice to have it, and definitely it should not be lost, but I think that this logic should be in my custom layers (when I make the PR to add them).
Otherwise, it's the only place in these layers where we mention parameter sharing / fold of the parameter being different from the layers fold
|
In general, this looks quite good to me. Two point that I raised (1) remove reference to parameter sharing, (2) implement the logic for gaussian layers (I already have it and I believe Dylan has it also). One thing that does strike me is the absence of tests, I think it should be quite easy to manually create a circuit to follow an objective distribution and compare the distribution of the samples to the objective distribution. |
as per title. related to #403.
use it as follows:
what I got from the MNIST circuit in the notebook:
