april-tools / cirkit

a python framework to build, learn and reason about probabilistic circuits and tensor networks
https://cirkit-docs.readthedocs.io/en/latest/
GNU General Public License v3.0
71 stars 1 forks source link

Dimension inconsistency in exp family input layer #93

Closed lkct closed 11 months ago

lkct commented 1 year ago

the output of this https://github.com/april-tools/cirkit/blob/7d57234ed8234a9d86c77cfdf4f88d0a0019a35c/cirkit/layers/exp_family/exp_family.py#L166 cannot be the input of this https://github.com/april-tools/cirkit/blob/7d57234ed8234a9d86c77cfdf4f88d0a0019a35c/cirkit/layers/exp_family/exp_family.py#L201 because d and r does not match.

It should be investigated.

To keep a reference: the old shape meanings: 6eb61b495e61d823939985ff962437989b987dd9


after this is fixed, we can introduce "named tensors" to guarantee consistency. https://pytorch.org/docs/stable/named_tensor.html

loreloc commented 1 year ago

What is a case where it raises an exception? I think those two einsums can be rewritten as follows.

crucial_quantity_einsum = torch.einsum("dipj,bdj->bdip", theta, self.suff_stats)
return torch.einsum("bdip,dpf->fib", output, self.scope_tensor)

using the convention in #112 .

lkct commented 1 year ago

try a 3 channel input


UPDATE

Also ref: einsums branch at 6eb61b495e61d823939985ff962437989b987dd9

arranger1044 commented 1 year ago

can we consider this closed @antoniomari?

lkct commented 11 months ago

I'm picking this up.