Closed ColsonZhang closed 3 years ago
Hi @ColsonZhang , we should be able to support do any float values for the paramters. The problem might be from save_as_dot
, which version of the library are you using currently? So, I can take a closer look.
In the latest released version 0.3
we have removed the save_as_dot
option as of now. If you can tell me more about your use-case I can see what would be the best substitute for saving the circuits, or we can try adding back support for save_as_dot
.
Thanks for your reply .
The version I'm using is v0.2.3
.
My research aims at constructing the hardware acceleration for the probabilistic circuits using the FPGA or the ASIC. So I want to use the ProbabilisticCircuits.jl
to generate some benchmark and I try to use the save_as_dot
to save the circuits.
Actually I just need one way to export the parameters and the structures of the circuits to a text file which I can easily deal with. But I have not find a proper function to do this in the manual.
And I have another question about the parameters' format. During the training period, can I strictly restrict the parameter' values in an exact range , like [ 4/4, 3/4, 2/4, 1/4, 0/4 ] ( the format can be expressed easily in binary format ) other than the floating point format.
Hi, if only constraint is having a parsable file you can save the circuit using our new format (in v0.3
), its a human-readable and easy to parse format for circuits, you can save as follows, if you end the name of the file with ".jpc" it automatically saves the circuit in that format:
X1, X2, X3 = literals(ProbCircuit, 3)
pc = 0.28 * (X1[1] *
(0.25X2[1] + 0.75X3[2])) +
0.72 * (X1[2] *
(0.44X2[2] + 0.56X3[1]))
write("pc-test.jpc", pc)
Note that the paramters will be saved in log domain, so have to exponetinate the numbers to get the actual paramters.
c this file was saved by ProbabilisticCircuits.jl
c ids of jpc nodes start at 0
c jpc nodes appear bottom-up, children before parents
c
c file syntax:
c jpc count-of-jpc-nodes
c L id-of-literal-jpc-node id-of-vtree literal
c P id-of-sum-jpc-node id-of-vtree number-of-children {child-id}+
c S id-of-product-jpc-node id-of-vtree number-of-children {child-id}+ {log-probability}+
c
jpc 11
L 0 0 1
L 1 0 2
L 2 0 -3
S 3 0 2 1 -1.3862943611198906 2 -0.2876820724517809
P 4 0 2 0 3
L 5 0 -1
L 6 0 -2
L 7 0 3
S 8 0 2 6 -0.8209805520698302 7 -0.579818495252942
P 9 0 2 5 8
S 10 0 2 4 -1.2729656758128873 9 -0.3285040669720361
For the second questions about parameters depends how you learn the circuits? Are you learning both structure and paramters from data, or specfying circuit manually like example above? We currently don't support that kind of limit on paramter range but should be doable buy some code modification.
Thank you so much, The method will be helpful.
As for the parameters, the expected way is learning both structure and parameters from data. Because I plan to adopt the integer add and multiplication operation instead of floating point add and multiplication operation due to the limitation of the hardware resource. And this will demand the parameters' values in a specific range.
Actually, there are maybe 2 ways to get the suitable probabilistic circuits. One way is to encode the parameters of the normal trained model , but this will cause the giant precision loss. The other way is to use the specific parameter range to train the model, which will be better than the first way as it's supervised.
I see, rounding paramters might be a good option too. By specific range do you mean having rational numbers as paramters? Or does it have to be interger? For your second option, would mainly need to customized the optimization for paramter learning part.
When I read the Quick Demo, I began to wonder the decimal digits of the parameters.
So I try to modify the decimal digits from 1 decimal place to 2 decimal places like this.
However, when I open the txt file and check it, I find that the parameters are set the format of 2 decimal places automatically. So, the decimal digits of the parameters only support one decimal place?