How to save an unrolled network in pySmile?

The engine.
Post Reply
pradhanojas
Posts: 3
Joined: Wed Jan 27, 2021 2:36 pm

How to save an unrolled network in pySmile?

Post by pradhanojas »

I want to unroll a dynamic Bayesian network model and write the unrolled network using the write_file() command. However, the original rolled network can only be saved into a .xdsl file. I understand that the unrolled network is an independent model but I haven't been able to figure out the correct way to call the unrolled network and save it into a .xdsl file. Seems like I am missing something here. Thank you
shooltz[BayesFusion]
Site Admin
Posts: 1325
Joined: Mon Nov 26, 2007 5:51 pm

Re: How to save an unrolled network in pySmile?

Post by shooltz[BayesFusion] »

You need to call Network.unroll first to obtain an UnrollResults object. One of its members contains a reference to the unrolled network. Use Network.write_file to save this network.

(I assume you're using PySMILE based on the write_file comment in your message).
pradhanojas
Posts: 3
Joined: Wed Jan 27, 2021 2:36 pm

Re: How to save an unrolled network in pySmile?

Post by pradhanojas »

That works! Thanks a lot
Yang Yajie
Posts: 31
Joined: Thu Mar 19, 2020 11:49 am

Re: How to save an unrolled network in pySmile?

Post by Yang Yajie »

may i ask how you store the unrolled DBN succesfully? i use below two row codes, but the results shown that i only save original dbn again. could you please tell me how you did that part?

pysmile.UnrollResults = net.unroll()
net.write_file('unrolledDBN.xdsl')
piotr [BayesFusion]
Site Admin
Posts: 44
Joined: Mon Nov 06, 2017 6:41 pm

Re: How to save an unrolled network in pySmile?

Post by piotr [BayesFusion] »

UnrollResults contains unrolled PyNetwork and mapping (an array). You can simply save unrolled network by write_file method call e.g.

Code: Select all

unroll_results = net.unroll()
unroll_results.write_file("filename.xdsl")
Yang Yajie
Posts: 31
Joined: Thu Mar 19, 2020 11:49 am

Re: How to save an unrolled network in pySmile?

Post by Yang Yajie »

thank you very much! But when I use these two rows to save the unrolled network, it tells me " AttributeError": 'pysmile.UnrollResults' object has no attribute ' write_file'.
I use dir(pysmile.UnrollResults),write_file is not the attribute of pysmile.UnrollResults, as shown in attached picture.

could you please tell me how to store it then? thank you very much!
Attachments
WechatIMG4.jpeg
WechatIMG4.jpeg (254.71 KiB) Viewed 187 times
piotr [BayesFusion]
Site Admin
Posts: 44
Joined: Mon Nov 06, 2017 6:41 pm

Re: How to save an unrolled network in pySmile?

Post by piotr [BayesFusion] »

This is my mistake in the previous post - use write_file method on unrolled property.

Code: Select all

unroll_results.unrolled.write_file("filename.xdsl")
Post Reply