Extract a part of a nngraph model after loading it

32 views
Skip to first unread message

Marceau C.

unread,
Jul 5, 2016, 12:13:24 PM7/5/16
to torch7
I downloaded a trained model that is using nngraph.
I want to be able to cut the graph in two, to add my personal stuff in the middle.
Instead of
Z = model:forward( {X1, X2} )

I want to do
Y = modelA:forward( {X1, X2} )
Y = process(Y)
Z = modelB:forward( {Y} )

Is this possible, or is the only way to do it is to extracts nodes one by one to rebuild two models ?

And if I want to do it node by node, what is the proper way to do it ? There seem to be redundancy in the model data structure.
Should I do model.fg.nodes[1].data.module to access the content of each node and then rebuild the nngraph ?

As I am not used to Torch (and lua) I don't know what is the proper way to do it.
Also, how can I manually extract each tensor and save it in a format that can be loaded by Numpy ?

Thanks.

Seokju Lee

unread,
Oct 17, 2017, 3:04:54 AM10/17/17
to torch7
How did you solve this issue?

2016년 7월 6일 수요일 오전 1시 13분 24초 UTC+9, Marceau C. 님의 말:

Ronak Kosti

unread,
Oct 18, 2017, 5:13:03 AM10/18/17
to torch7
Hi guys, 

I am also looking for something similar. Did you find the solution?

Marceau C.

unread,
Oct 18, 2017, 8:58:47 AM10/18/17
to torch7 on behalf of Ronak Kosti
Hi,

If I remember well, I didn't find a solution and solved my problem another way.
Sorry.

--
You received this message because you are subscribed to a topic in the Google Groups "torch7" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/torch7/-pMv4MPkuzs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to torch7+unsubscribe@googlegroups.com.
To post to this group, send email to tor...@googlegroups.com.
Visit this group at https://groups.google.com/group/torch7.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages