def __init__(self, var_list):
assigns = []
shapes = map(var_shape, var_list)
total_size = sum(np.prod(shape) for shape in shapes)
self.theta = theta = tf.placeholder(tf.float32, [total_size])
start = 0
assigns = []
for (shape, v) in zip(shapes, var_list):
size = np.prod(shape)
assigns.append(
tf.assign(
v,
tf.reshape(
theta[
start:start +
size],
shape)))
start += size
self.op = tf.group(*assigns)
评论列表
文章目录