[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf_agents.utils.common.soft_variables_update\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/utils/common.py#L251-L347) |\n\nPerforms a soft/hard update of variables from the source to the target. \n\n tf_agents.utils.common.soft_variables_update(\n source_variables,\n target_variables,\n tau=1.0,\n tau_non_trainable=None,\n sort_variables_by_name=False\n )\n\n| **Note:** **when using this function with TF DistributionStrategy** , the `strategy.extended.update` call (below) needs to be done in a cross-replica context, i.e. inside a merge_call. Please use the Periodically class above that provides this wrapper for you.\n\nFor each variable v_t in target variables and its corresponding variable v_s\nin source variables, a soft update is:\nv_t = (1 - tau) \\* v_t + tau \\* v_s\n\nWhen tau is 1.0 (the default), then it does a hard update:\nv_t = v_s\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------------------|-----------------------------------------------------------------------------------------------------------------------|\n| `source_variables` | list of source variables. |\n| `target_variables` | list of target variables. |\n| `tau` | A float scalar in \\[0, 1\\]. When tau is 1.0 (the default), we do a hard update. This is used for trainable variables. |\n| `tau_non_trainable` | A float scalar in \\[0, 1\\] for non_trainable variables. If None, will copy from tau. |\n| `sort_variables_by_name` | A bool, when True would sort the variables by name before doing the update. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| An operation that updates target variables from source variables. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|--------------------------------------------------------------------------------------------------------------------------|\n| `ValueError` | if `tau not in [0, 1]`. |\n| `ValueError` | if `len(source_variables) != len(target_variables)`. |\n| `ValueError` | \"Method requires being in cross-replica context, use get_replica_context().merge_call()\" if used inside replica context. |\n\n\u003cbr /\u003e"]]