Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13951

PyTorch: load weights from another model without saving

$
0
0

Assume that I have two models in PyTorch, how can I load the weights of model 1 by weights of model 2 without saving the weights?

Like this:

model1.weights = model2.weights

In TensorFlow I can do this:

variables1 = model1.trainable_variablesvariables2 = model2.trainable_variablesfor v1, v2 in zip(variables1, variables2):    v1.assign(v2.numpy())

Viewing all articles
Browse latest Browse all 13951

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>