MCPcopy
hub / github.com/tensorlayer/TensorLayer / assign_weights

Function assign_weights

tensorlayer/files/utils.py:1992–2020  ·  view source on GitHub ↗

Assign the given parameters to the TensorLayer network. Parameters ---------- weights : list of array A list of model weights (array) in order. network : :class:`Layer` The network to be assigned. Returns -------- 1) list of operations if in graph mode

(weights, network)

Source from the content-addressed store, hash-verified

1990
1991
1992def assign_weights(weights, network):
1993 """Assign the given parameters to the TensorLayer network.
1994
1995 Parameters
1996 ----------
1997 weights : list of array
1998 A list of model weights (array) in order.
1999 network : :class:`Layer`
2000 The network to be assigned.
2001
2002 Returns
2003 --------
2004 1) list of operations if in graph mode
2005 A list of tf ops in order that assign weights. Support sess.run(ops) manually.
2006 2) list of tf variables if in eager mode
2007 A list of tf variables (assigned weights) in order.
2008
2009 Examples
2010 --------
2011
2012 References
2013 ----------
2014 - `Assign value to a TensorFlow variable <http://stackoverflow.com/questions/34220532/how-to-assign-value-to-a-tensorflow-variable>`__
2015
2016 """
2017 ops = []
2018 for idx, param in enumerate(weights):
2019 ops.append(network.all_weights[idx].assign(param))
2020 return ops
2021
2022
2023def load_and_assign_npz(name=None, network=None):

Callers 6

find_top_modelMethod · 0.90
restore_paramsFunction · 0.90
restore_modelFunction · 0.90
restore_paramsFunction · 0.90
restore_paramsFunction · 0.90
load_and_assign_npzFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…