Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

how to get the weights of layers

Open seanxh opened this issue 8 years ago • 1 comments

scope = fluid.global_scope();
scope.find_var('fc_0.w_0').get_tensor().set([1,2,3,4],fluid.CPUPlace())

1、I know the tensor has a set api can specified weights. But it seems the tensor doesn't have a get api ?

2、It seems set can change the tensor's shape?? I can set an arbitrary ndarray with any shape, that the tensor changed to the given shape??

seanxh avatar May 17 '18 06:05 seanxh

  1. There is no interface to get the tensor date directly and currently the way to get weights' data is to run the executor to fetch the tensor out.
  2. set indeed change the tensor's shape. When running the executor, the actual data and shape will be used.

guoshengCS avatar May 17 '18 07:05 guoshengCS