MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / static_cond

Function static_cond

tensorflow/contrib/layers/python/layers/utils.py:171–194  ·  view source on GitHub ↗

Return either fn1() or fn2() based on the boolean value of `pred`. Same signature as `control_flow_ops.cond()` but requires pred to be a bool. Args: pred: A value determining whether to return the result of `fn1` or `fn2`. fn1: The callable to be performed if pred is true. fn2: The

(pred, fn1, fn2)

Source from the content-addressed store, hash-verified

169
170
171def static_cond(pred, fn1, fn2):
172 """Return either fn1() or fn2() based on the boolean value of `pred`.
173
174 Same signature as `control_flow_ops.cond()` but requires pred to be a bool.
175
176 Args:
177 pred: A value determining whether to return the result of `fn1` or `fn2`.
178 fn1: The callable to be performed if pred is true.
179 fn2: The callable to be performed if pred is false.
180
181 Returns:
182 Tensors returned by the call to either `fn1` or `fn2`.
183
184 Raises:
185 TypeError: if `fn1` or `fn2` is not callable.
186 """
187 if not callable(fn1):
188 raise TypeError('fn1 must be callable.')
189 if not callable(fn2):
190 raise TypeError('fn2 must be callable.')
191 if pred:
192 return fn1()
193 else:
194 return fn2()
195
196
197def smart_cond(pred, fn1, fn2, name=None):

Callers 1

smart_condFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected