March 2019
Intermediate to advanced
184 pages
4h 57m
English
Last but not least, we will code the utility functions in utils.py. We will import the necessary packages, and we'll also define the update_target_graph() function that we used earlier. It takes the scope of the source and destination parameters as arguments, and it copies the parameters from the source to the destination:
import numpy as npimport tensorflow as tffrom random import choice# copy model params def update_target_graph(from_scope,to_scope): from_params = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, from_scope) to_params = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, to_scope) copy_ops = [] for from_param,to_param in zip(from_params,to_params): copy_ops.append(to_param.assign(from_param)) return copy_ops ...
Read now
Unlock full access