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)
| 1990 | |
| 1991 | |
| 1992 | def 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 | |
| 2023 | def load_and_assign_npz(name=None, network=None): |
no outgoing calls
no test coverage detected
searching dependent graphs…