Skip to content

rlefmann/SPN.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SPN

This Julia package is an implementation of sum-product networks, including inference and parameter learning.

Documentation

The documentation of this package can be found here.

Create an SPN

s = SumNode()

p1 = ProdNode()
p2 = ProdNode()
p3 = ProdNode()

s1 = SumNode()
s2 = SumNode()
s3 = SumNode()
s4 = SumNode()

i1 = IndicatorNode(1,1)
i2 = IndicatorNode(1,0)
i3 = IndicatorNode(2,1)
i4 = IndicatorNode(2,0)

connect!(s,p1,weight=0.5)
connect!(s,p2,weight=0.2)
connect!(s,p3,weight=0.3)

connect!(p1,s1)
connect!(p1,s3)
connect!(p2,s1)
connect!(p2,s4)
connect!(p3,s2)
connect!(p3,s4)

connect!(s1,i1,weight=0.6)
connect!(s1,i2,weight=0.4)
connect!(s2,i1,weight=0.9)
connect!(s2,i2,weight=0.1)

connect!(s3,i3,weight=0.3)
connect!(s3,i4,weight=0.7)
connect!(s4,i3,weight=0.2)
connect!(s4,i4,weight=0.8)

spn = SumProductNetwork(s)

Evaluate the SPN

x = [true, false]
eval!(spn, x)
@show spn.root.logval

About

Sum-Product Networks, implemented in Julia.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages