Skip to content

Setting weights after initialization #1520

Answered by frankfliu
nwjnilsson asked this question in Q&A
Discussion options

You must be logged in to vote

@Applooza
Instead of calling setArray(), you can getArray() and then copy the data into it:

NDArray array = target_net.getBlock().getParameters().get(params.getKey()).getArray();
params.getValue().getArray().copyTo(array);

The reason we block the setArray() is assume the shape and data type should never change after initialized.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@nwjnilsson
Comment options

@zachgk
Comment options

@nwjnilsson
Comment options

Answer selected by nwjnilsson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants