-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiling an SDD into a PSDD #53
Comments
I think you can try to do the following to get from LogicCircuit to ProbCircuit. (gotta douable check if it works with your code snippet) pc = ProbCircuit(sdd); An example in the code here: https://github.com/Juice-jl/ProbabilisticCircuits.jl/blob/0930ca0c6b9588908793f7dc942e5aa63e0d5739/test/plain_prob_nodes_tests.jl#L9-L14 But yeah, thanks for bringing this up, I think this would be a good addition to our docs and make it an easy API for it (if the one I suggested does not work). |
Hi Pasha. Thanks for the quick reply. Unfortunately your suggestion didn't work :( I get this error
When trying to smooth the SDD before with
|
Uh yes, currently the smoothing does not work properly for structured decomposable circuits (for example psdds) Tractables/LogicCircuits.jl#43. In addition you might need to also do How do you make the SDDs, do you make them in Juice or do you have them as sdd format? One quick hack until we fix these could be changing your .sdd files and add paramters (arbitrary) to them so they become .psdd files and then load them from file in Juice. Then, you can call paramter learning or even structure learning on top of that as needed. Or if you are making the circuits in Juice, can directly do them in ProbCircuit. Some examples here: https://github.com/Juice-jl/JuiceExamples/blob/master/Juice-Example.ipynb For example: X1, X2, X3 = literals(ProbCircuit, 3)
pc = 0.3 * (X1[1] *
(0.2X2[1] + 0.8X3[2])) +
0.7 * (X1[2] *
(0.4X2[2] + 0.6X3[1])) |
I'm compiling them from a DNF file. dnf = load_dnf(dnf_file)
sdd = compile(SddManager(Vtree(n, :random)), dnf) |
Hi, So I hacked something up to convert SDDs to PSDDs, and it does seem to work on the CNFs I'm working on. Once I have the time I'll open a PR and do some other tests so we can have this in Juice. Thanks |
Awesome, thanks, this would be a good feature, to have. |
Hi, so it seems I'm more or less struggling with a very similar issue. I'm starting from .sdd files, rather than from a dnf. But ultimately, the goal is also to convert the sdd into a psdd and learn the parameters on data. Currently, this is my workflow (as per a suggestion made above):
And that seems to work well enough. However, this then fails as soon as I want to actually use this PSDD circuit, for instance to compute likelihoods of fully observed data like so;
This is where I get stuck on the following error:
Any pointers to what I am doing wrong? Thanks. |
@eliavw yeah it seems there is some issue with smoothing. We are trying to simplify this workflow but have not pushed the changes yet. In the meanwhile: If the SDD you have is already smooth then you don't have to call smoothing: Have you tried the following? Or maybe even without the propogate_constants.
|
@RenatoGeh What solution did you end up using in the end? Basically trying to streamline the whole workflow in different situtaions so wanted to know what solved the problem for you. For now we have this two scenarios:
The main issue seems to come from smoothing (Tractables/LogicCircuits.jl#43). The |
I wrote a quick hack to convert an SDD into a PSDD. Strangely, although it did work in my use cases (it outputs a smooth, decomposable, deterministic, vtree respecting PSDD consistent with the CNF/DNF), it sometimes doesn't work. Anyway, I kept this as a WIP PR (#56) until I find out what's wrong. |
@khosravipasha , thanks for the quick reply! So, as for your suggestion, that does not work unfortunately. The SDDs I want to convert to PSDDs are compiled using the pysdd package, which just calls the SDD package. So, just to provide some info on where I'm at;
yields this error
Which I'm guessing is due to the original SDD not being smooth, as you already mentioned. To be clear
yields False, so I do know for a fact my SDD obtained from the SDD package is not smooth. So the question seems to boil down to finding a workflow to somehow enforce smooth SDDs; either on the side of the SDD package itself, or here. Or finding a creative hack that circumvents this issue altogether. Anyways, thanks for the feedback already. I'm now gonna take a closer look at @RenatoGeh solution and see if it could apply to my case as well. |
Hi, so just to give you an update on what works and what doesn't. Disregarding my SDD and just importing my BK as CNF and following @RenatoGeh's workflow seems to work well on my (toy) data for now. The PSDDs that come out behave as expected. I also tried a bit more in converting my SDDs directly;
which sure enough works all the way up to and including parameter estimation. But... if you then do an EVI-query the results are off (probabilities do not sum to one), so somewhere along the way the workflow above still introduces errors. Going forward, I'll disregard my SDDs for the time being and directly read in BK from CNF files. Thanks for the feedback and quick replies here. |
@eliavw Good, glad that the workaround works for now. This boils down to the smoothness issue, we will be fixing the smoothness issue, for us till now it has not been a big deal since we direclty learn psdds from data. Easy conversion of SDD/CNF/DNF into probabilistic circuits is definely something we like to support.
Yeah, in most cases we impclicity assume smoothness for our query implementations. I will try to make those assumptions more explicit in the documentation. Without assuming smoothnes the implementations become a bit more complicated. |
With Tractables/LogicCircuits.jl#69, structured smoothing should be supported (though for now you have to smooth the logic circuit). You can see the new tests in that PR for examples of how to use structured smoothing - the only requirement is that you propagate constants first. Once you've done that you can convert a structured logic circuit to a probabilistic one with Let me know if you find something that doesn't work or cases that break smoothing. |
Hi,
I don't know if I'm missing something from the docs or the code, but I couldn't seem to find any way to convert an SDD into a PSDD. What I want to do is load an SDD from a CNF/DNF like so
and then learn through the LearnPSDD transformations. Except
struct_learn
only takesStructProbCircuit
s as argument and I couldn't find any function in Juice to convert anSddNode
intoStructProbCircuit
. Is there no such function?Thanks
The text was updated successfully, but these errors were encountered: