How to get weights of the NN

24 views
Skip to first unread message

Efe Bakioglu

unread,
Apr 25, 2024, 8:49:57 AM4/25/24
to Neural Network Console Users
Hi,
I'd like to download the weights and biases of the layers of my trained NN, just to use in an offline application of mine, is it possible? I couldn't find any way to even see them.
Regards, Efe

Tomonobu Tsujikawa

unread,
Apr 26, 2024, 5:30:27 AM4/26/24
to Neural Network Console Users
Sorry, I missed to post.

Hi,
Do you use Neural Network Console Cloud?
If so, you can download nnp/nnb/onnx file from each job on training tab.
.nnp (just zip archive) contains network graph and parameters written by h5 or protobuf format.

If you use Neural Network Console Windows, the files are available on project directly.


2024年4月25日木曜日 21:49:57 UTC+9 efeba...@gmail.com:

Efe Bakioglu

unread,
Apr 26, 2024, 7:51:44 AM4/26/24
to Neural Network Console Users
Thank you very much.
Yes I am using Neural Network Console Cloud. I will have a try.

Efe Bakioglu

unread,
Apr 26, 2024, 11:25:00 AM4/26/24
to Neural Network Console Users
Found it, wanted to share the basic python code I used, both for nnp and onnx files.
Thank you again.

import numpy
from nnabla.utils.nnp_graph import NnpLoader

nnp = NnpLoader('result_train_best.nnp')
net = nnp.get_network("MainRuntime")
c = net.variables["Convolution_2/conv/W"]
print(c.d)

import onnx, onnxruntime
onnx_model = onnx.load(
'result.onnx' )
for n in onnx_model.graph.initializer:
    print(onnx.numpy_helper.to_array(n))
Reply all
Reply to author
Forward
0 new messages