def read_variables(var_or_list): """Get the value from a variable. :param var_or_list: tf.Variable. :return: numpy.array value. """ session = ph.get_session() return session.run(var_or_list)
def write_variables(var_or_list, values): """Set the value to a variable. :param var_or_list: tf.Variable. :param values: numpy.array value. """ session = ph.get_session() if isinstance(var_or_list, (tuple, list)): for var, value in zip(var_or_list, values): var.load(value, session) else: var_or_list.load(values, session)