8d77bc5f267a49ed890222039f9ee058cca7f22f,keras/utils/control_flow_util.py,,smart_cond,#Any#Any#Any#Any#,88
Before Change
if not callable(true_fn):
raise TypeError("`true_fn` must be callable.")
if not callable(false_fn):
raise TypeError("`false_fn` must be callable.")
pred_value = constant_value(pred)
if pred_value is not None:
if pred_value:
return true_fn()
else:
return false_fn()
else:
return tf.compat.v1.cond(pred, true_fn=true_fn, false_fn=false_fn,
After Change
if isinstance(pred, tf.Variable):
return tf.compat.v1.cond(
pred, true_fn=true_fn, false_fn=false_fn, name=name)
return smart_module.smart_cond(
pred, true_fn=true_fn, false_fn=false_fn, name=name)
def constant_value(pred): // pylint: disable=invalid-name
Return the bool value for `pred`, or None if `pred` had a dynamic value.
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
Instances
Project Name: keras-team/keras
Commit Name: 8d77bc5f267a49ed890222039f9ee058cca7f22f
Time: 2021-03-01
Author: scottzhu@google.com
File Name: keras/utils/control_flow_util.py
Class Name:
Method Name: smart_cond
Project Name: keras-team/keras
Commit Name: 1dc67f374cde47a721e5fe5d9237bc2573bda2f0
Time: 2017-07-06
Author: souptc@gmail.com
File Name: keras/backend/cntk_backend.py
Class Name:
Method Name: in_train_phase
Project Name: deepmipt/DeepPavlov
Commit Name: 8e0dea3d8fa8efecc9b3eaff721f997e08e74e57
Time: 2018-02-25
Author: yoptar@gmail.com
File Name: deeppavlov/core/commands/train.py
Class Name:
Method Name: train_model_from_config