microsoft / onnxjs

ONNX.js: run ONNX models using JavaScript
Other
1.75k stars 130 forks source link

Is there any function to ouput weight matrix for layers? #306

Open zhoyifan opened 3 years ago

zhoyifan commented 3 years ago

Just like this function in tensorflow.

https://www.tensorflow.org/api_docs/python/tf/keras/layers/Layer#get_weights https://js.tensorflow.org/api/latest/#tf.layers.Layer.getWeights

fs-eire commented 2 years ago

There is not such API to get weights directly as far as I know. But there are 3 ways to get them:

  1. try use onnx(python package)
  2. use protobuf library to read from a ONNX model. The protobuf def file is at https://github.com/onnx/onnx/blob/master/onnx/onnx.proto3
  3. use https://github.com/lutzroeder/netron to visualize your model and dump the weights in GUI.