Visualizing tools for the circuits
wenzhe-li opened this issue · 2 comments
wenzhe-li commented
I found it useful to visualize the circuit in programming. Below is a naive print function for probabilistic circuits, but we can do better with julia graph visualization tools : )
function print_circuit_dfs(node::ProbΔNode, tab=0, weight=0)
for i = 1 : tab
print("> ")
end
if node isa ProbLiteral
print("Literal ", lit2var(literal(node)), " ", positive(node), " ")
if weight > 0
print("(", weight, ")")
end
print("\n")
elseif node isa Prob⋀
print("AND ")
if weight > 0
print("(", weight, ")")
end
print("\n")
for i in 1 : length(node.children)
print_circuit_dfs(node.children[i], tab + 1)
end
elseif node isa Prob⋁
print("OR ")
if weight > 0
print("(", weight, ")")
end
print("\n")
p_thetas = [exp(node.log_thetas[i]) for i in 1 : length(node.children)]
for i in 1 : length(node.children)
print_circuit_dfs(node.children[i], tab + 1, p_thetas[i])
end
else
println("ERROR ", node)
end
end
guyvdbroeck commented
Would be nice to use https://github.com/JuliaGraphs/GraphPlot.jl for this.
khosravipasha commented
GraphPlot does not support Tree of DAG layout it seems.