tensorflow_backend.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:keraflow 作者: ipod825 项目源码 文件源码
def switch(self, condition, then_expression, else_expression):
        '''Switches between two operations depending on a scalar value (int or bool).
        Note that both `then_expression` and `else_expression`
        should be symbolic tensors of the *same shape*.

        # Arguments
            condition: scalar tensor.
            then_expression: TensorFlow operation.
            else_expression: TensorFlow operation.
        '''
        x_shape = copy.copy(then_expression.get_shape())
        x = tf.python.control_flow_ops.cond(self.cast(condition, 'bool'),
                                            lambda: then_expression,
                                            lambda: else_expression)
        x.set_shape(x_shape)
        return x
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号